How to join multiple tables in GAQL?

2,733 views
Skip to first unread message

Daniel Chen

unread,
Jun 22, 2021, 12:00:19 PM6/22/21
to AdWords API and Google Ads API Forum
Hi,
I want to get the campaign bid modifiers and campaign budge amount along with the keyword performance report. Can I join campaign and campaign_criterion tables?

SELECT
      segments.date,
      campaign.id,
      ad_group.id,
      ad_group_criterion.criterion_id,
      segments.device,
      segments.ad_network_type,
      metrics.clicks,
      metrics.cost_micros,
      metrics.impressions,
      ad_group_criterion.effective_cpc_bid_micros,
      ad_group_criterion.position_estimates.first_page_cpc_micros,
      ad_group_criterion.quality_info.quality_score,
      metrics.search_impression_share,
      metrics.search_exact_match_impression_share,
      metrics.search_rank_lost_impression_share,
      metrics.top_impression_percentage,
      metrics.absolute_top_impression_percentage,
      metrics.search_top_impression_share,
      metrics.search_absolute_top_impression_share,
      cr.bid_modifier,
      cp.campaign_budget.amount_micros
    FROM keyword_view kv
    LEFT JOIN campaign cp ON (cp.campaign.id = kw.campaign.id)
    LEFT JOIN campaign_criterion cr ON (cr.criterion_id = cp.campaign.id)
      WHERE segments.date BETWEEN '2021-04-01' AND '2021-04-01'
        AND campaign.id in (1053569228,9444625651)
        AND metrics.impressions > 0

The query validator here reports errors:
The input provided in the FROM clause, 'keyword_view kv LEFT JOIN campaign cp ON (cp.campaign.id = kw.campaign.id) LEFT JOIN campaign_criterion cr ON (cr.criterion_id = cp.campaign.id)', is not a valid resource.
   
What's going wrong here? How should I do this?

Thanks,
Daniel

Google Ads API Forum Advisor

unread,
Jun 24, 2021, 2:13:11 AM6/24/21
to adwor...@googlegroups.com

Hello Daniel,

Thank you for raising this to us.

Please note that JOIN isn't supported in both GAQL and AWQL. To help you build your query, we suggest that you use the Query Builder specific to the keyword_view instead or use the Query Validator.

Hope this helps.

Regards,

Google Logo
Mark Kevin Albios
Google Ads API Team
 


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