Nested where clause and OR clauses

374 views
Skip to first unread message

Kristijan Novaković

unread,
May 10, 2022, 10:28:27 AM5/10/22
to Google Ads API and AdWords API Forum
Is it possible to write nested where clause in Ads API and is it possible to use OR key? If so, how, I couldn't find anything in docs.

Google Ads API Forum Advisor

unread,
May 11, 2022, 10:56:53 AM5/11/22
to elda...@gmail.com, adwor...@googlegroups.com

Hello Kristijan,

Thanks for reaching out to the Google Ads API support. I am afraid if it is allow to do that because all reports GAQL queries are predefined and has to be selectable. In case if you want to check on your end then please refer to the  Google Ads Query Builder tool for the query validation on Google Ads API. Please share your GAQL query with us so we can also validate for you. Let me know if you have any questions on this.

Please send the requested details via the Reply privately to the author option. If this option is not available, you may send the details directly to our googleadsapi-support@google.com alias by referring to this thread.

Best regards,

Google Logo
Jakeia Sabrina
Google Ads API Team
 

ref:_00D1U1174p._5004Q2arRmI:ref

Kristijan Novaković

unread,
May 11, 2022, 11:52:06 AM5/11/22
to Google Ads API and AdWords API Forum
Here is an example where OR could be useful:
SELECT customer.id, metrics.impressions, metrics.all_conversions FROM customer where metrics.impressions != 0 or metrics.all_conversions != 0 (using and in stead of or is valid)

That same query is where nesting is required, for example:
SELECT customer.id, metrics.impressions, metrics.all_conversions FROM customer where segments.date >= '2022-04-01' and segments.date <= '2022-04-30' and (metrics.impressions != 0 or metrics.all_conversions != 0)

On Wednesday, May 11, 2022 at 4:56:53 PM UTC+2 adsapi wrote:

Hello Kristijan,

Thanks for reaching out to the Google Ads API support. I am afraid if it is allow to do that because all reports GAQL queries are predefined and has to be selectable. In case if you want to check on your end then please refer to the  Google Ads Query Builder tool for the query validation on Google Ads API. Please share your GAQL query with us so we can also validate for you. Let me know if you have any questions on this.

Please send the requested details via the Reply privately to the author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias by referring to this thread.

Best regards,

don....@gmail.com

unread,
Jul 12, 2022, 7:25:40 AM7/12/22
to Google Ads API and AdWords API Forum
I second this request we would like to do query like

SELECT
ad_group_ad.ad.name,
ad_group_ad.ad.call_ad.headline1,
ad_group_ad.ad.expanded_text_ad.headline_part1,

FROM ad_group_ad
WHERE ad_group.status IN ('ACTIVE', 'PAUSED')
AND (metrics.cost_micros > 0 OR metrics.clicks > 0)
AND segments.date = '2022-07-01'


but can't do this..

Google Ads API Forum Advisor

unread,
Jul 12, 2022, 11:50:21 AM7/12/22
to don....@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

Upon taking look at your query, I noticed that you query is incorrect. You can use query validator tools. You can not use ad_group.status field as active. We already raised your request for an option to directly exclude 0 metrics rows and/or to offer an OR statement capability in Ads API. You may monitor our blog for an update.

SELECT
ad_group_ad.ad.name,
ad_group_ad.ad.call_ad.headline1,
ad_group_ad.ad.expanded_text_ad.headline_part1
FROM ad_group_ad
WHERE ad_group.status IN ('ENABLED', 'PAUSED')
AND  metrics.clicks > 0
AND segments.date = '2022-07-01'

Let me know if you have any question.

Thanks,
Google Logo
Nirmitabahen Gaurav
Google Ads API Team
 


ref:_00D1U1174p._5004Q2arRmI:ref
Reply all
Reply to author
Forward
0 new messages