ORDER BY is not allowed on non-selected metrics or non-selected segments.
Limit the number of results
You can limit the total number of results returned using the LIMIT clause.
Combining this with results ordering, you can produce "top N" reports, such as a
report containing the five products with the highest impressions over the last
30 days:
[null,null,["Last updated 2025-08-13 UTC."],[[["\u003cp\u003eThe Merchant API is the new version of the Content API for Shopping and represents the future of product data integration.\u003c/p\u003e\n"],["\u003cp\u003eYou can order results with the \u003ccode\u003eORDER BY\u003c/code\u003e clause using fields and \u003ccode\u003eASC\u003c/code\u003e or \u003ccode\u003eDESC\u003c/code\u003e for ascending or descending order respectively.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eLIMIT\u003c/code\u003e clause enables you to specify the maximum number of returned results and can be combined with \u003ccode\u003eORDER BY\u003c/code\u003e to generate "top N" reports.\u003c/p\u003e\n"],["\u003cp\u003eWhile a query's maximum result limit is 1000 rows, pagination with \u003ccode\u003epageToken\u003c/code\u003e is necessary for retrieving additional results beyond this limit.\u003c/p\u003e\n"],["\u003cp\u003eFiltering using the \u003ccode\u003eWHERE\u003c/code\u003e clause on metrics necessitates their selection in the query.\u003c/p\u003e\n"]]],["The Merchant API beta, a new version of the Content API for Shopping, is introduced. You can order response rows using the `ORDER BY` clause with `ASC` or `DESC` order for selected fields. The `LIMIT` clause restricts the total results, enabling \"top N\" reports. `ORDER BY` is limited to selected fields, and filtering (`WHERE`) is not available for metrics that aren't selected. The maximum number of rows returned is 1000, requiring pagination for more results.\n"],null,["# Order and limit results\n\nYou can specify the order of rows in your response using the `ORDER BY` clause,\nwhich consists of one or more comma-separated sequences of: \n\n FieldName ('ASC' | 'DESC')?\n\nIf you don't specify `ASC` or `DESC` after a field name, the Reporting API\ndefaults to `ASC`.\n\nThe following `ORDER BY` clause sorts a performance report by descending\nimpressions and ascending product offer IDs: \n\n ORDER BY metrics.impressions DESC, segments.offer_id ASC\n\n`ORDER BY` is not allowed on non-selected metrics or non-selected segments.\n\nLimit the number of results\n---------------------------\n\nYou can limit the total number of results returned using the `LIMIT` clause.\nCombining this with results ordering, you can produce \"top N\" reports, such as a\nreport containing the five products with the highest impressions over the last\n30 days:\n\n#### Example\n\n SELECT\n segments.offer_id,\n metrics.impressions\n FROM MerchantPerformanceView\n WHERE segments.date BETWEEN '2020-12-01' AND '2020-12-31'\n ORDER BY metrics.impressions DESC\n LIMIT 5;\n\n| **Note:** The maximimum number of rows you can retrieve from a query is 1000, even if your limit is higher. You have to issue consecutive requests with the `pageToken` for the remaining results. To learn more, see our pagination guide.\n\nFiltering (`WHERE` clause) is not allowed on **metrics** without selecting them."]]