با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
نتایج را سفارش دهید
می توانید ترتیب ردیف ها را در پاسخ خود با استفاده از عبارت ORDER BY
که از یک یا چند دنباله جدا شده با کاما تشکیل شده است، مشخص کنید:
FieldName ('ASC' | 'DESC')?
اگر ASC
یا DESC
بعد از نام فیلد مشخص نکنید، Google Ads API پیشفرض ASC
است.
بند ORDER BY
زیر یک گزارش در سطح کمپین را بر اساس نمایشهای نزولی و نام کمپین صعودی مرتب میکند:
ORDER BY metrics.impressions DESC, campaign.name ASC
سفارش ممنوع:
- با ویژگی های منابع انتخاب نشده
- با معیارهای غیر انتخابی
- توسط بخش های انتخاب نشده
- برای فیلدهایی از انواع زیر:
-
MESSAGE
- فیلدهای تکراری
- ویژگی های فیلدهای تکراری
تعداد نتایج را محدود کنید
شما می توانید تعداد کل نتایج بازگشتی را با استفاده از بند LIMIT
محدود کنید. با ترکیب این مورد با ترتیب نتایج، میتوانید گزارشهای «N برتر» تولید کنید، مانند گزارشی که شامل پنج کمپین با بیشترین تأثیرگذاری در 30 روز گذشته است:
SELECT
campaign.id,
campaign.name,
metrics.impressions
FROM campaign
WHERE segments.date DURING LAST_30_DAYS
ORDER BY metrics.impressions DESC
LIMIT 5
فیلتر کردن مجاز نیست:
- در بخشها بدون انتخاب آنها، به جز فیلدهای بخش تاریخ «هسته».
- فیلدهای بخش اصلی تاریخ عبارتند از
segments.date
، segments.week
، segments.month
، segments.quarter
و segments.year
.
- در فیلدهای هر نوع پیام به جز موارد اولیه (مانند: Int64Value، StringValue، و غیره)
- در ویژگی های فیلدهای تکراری از هر نوع پیام به جز موارد اولیه (مانند: Int64Value، StringValue، و غیره)
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-26 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-26 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eYou can control the order of results using the \u003ccode\u003eORDER BY\u003c/code\u003e clause, specifying fields and sort direction (ASC or DESC).\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eLIMIT\u003c/code\u003e clause lets you restrict the number of returned results, enabling "top N" reports when combined with \u003ccode\u003eORDER BY\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eOrdering is disallowed by attributes of non-selected resources, by non-selected metrics or segments, and for fields of type \u003ccode\u003eMESSAGE\u003c/code\u003e, repeated fields, or attributes of repeated fields.\u003c/p\u003e\n"],["\u003cp\u003eFiltering is restricted for segments without selection (excluding core date segments), fields of non-primitive message types, and attributes of repeated fields with non-primitive message types.\u003c/p\u003e\n"]]],[],null,["Order results\n-------------\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 Google Ads API defaults to\n`ASC`.\n\nThe following `ORDER BY` clause sorts a campaign-level report by descending\nimpressions and ascending campaign name: \n\n ORDER BY metrics.impressions DESC, campaign.name ASC\n\nOrdering is not allowed:\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n- By attributes of non-selected resources\n- By non-selected metrics\n- By non-selected segments\n- For fields of the following types:\n - `MESSAGE`\n - Repeated fields\n - Attributes of repeated fields\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,\nsuch as a report containing the five campaigns with the highest impressions\nover the last 30 days: \n\n SELECT\n campaign.id,\n campaign.name,\n metrics.impressions\n FROM campaign\n WHERE segments.date DURING LAST_30_DAYS\n ORDER BY metrics.impressions DESC\n LIMIT 5\n\nFiltering is not allowed:\n\n- On segments without selecting them, except for \"core\" date segment fields.\n - The core date segment fields are `segments.date`, `segments.week`, `segments.month`, `segments.quarter`, and `segments.year`.\n- On fields of any message type except primitives (e.g.: Int64Value, StringValue, etc.)\n- On attributes of repeated fields of any message type except primitives (e.g.: Int64Value, StringValue, etc.)"]]