This query is close to what I need but google_responsive_headlines.responsive_headlines has many rows to google_text_ads. I would like to have those results in the same row but not sure how to achieve that. Appreciate any advice!
SELECT google_responsive_headlines.responsive_headlines,
google_responsive_headlines.responsive_path_1,
google_responsive_headlines.responsive_path_2,
d.responsive_descriptions,
s.clicks,
s.cost,
s.impressions,
s.ad_id,
s.status,
s.final_url,
s.display_url
FROM
irene_db.google_responsive_descriptions d
INNER JOIN
(SELECT
SUM(clicks) AS clicks,
SUM(cost) AS cost,
SUM(impressions) AS impressions,
google_text_ads.ad_id,
google_text_ads.status,
google_text_ads.final_url,
google_text_ads.display_url
FROM
google_text_ads
WHERE
google_text_ads.customer_id = 144
AND (google_text_ads.date >= '2022-05-21'
AND google_text_ads.date <= '2022-06-21')
AND google_text_ads.status IN ('ENABLED')
AND google_text_ads.type IN ('EXPANDED_TEXT_AD' , 'RESPONSIVE_SEARCH_AD')
GROUP BY ad_id) s ON s.ad_id = d.ad_id
INNER JOIN
irene_db.google_responsive_headlines ON s.ad_id = google_responsive_headlines.ad_id
AND google_responsive_headlines.customer_id = 144
AND (google_responsive_headlines.date >= '2022-05-21'
AND google_responsive_headlines.date <= '2022-06-21')
group by google_responsive_headlines.responsive_headlines
LIMIT 50;
Here's my results...
How can I get responsive_headlines to be in separate columns and have the query return 1 row?
EDIT: The query result is the same in every other column except responsive_headline. There can be up to 15 of those per 1 row in google_text_ads. So is there anyway in my return query I can have responsive_headline1, responsive_headline2,... responsive_headline15.
responsive_headlines responsive_path_1 responsive_path_2 responsive_descriptions clicks cost impressions ad_id status final_url display_url customer_id date type
Retirement Plan Administration, RetirementPlan, Administration, Partner with[company name] to offer workplace retirement plan administration to your clients., 39, 133440000, 1332, [ad_id int], ENABLED, [weburl], , 144, 2022-05-21, RESPONSIVE_SEARCH_AD
We Help Financial Planners, RetirementPlan, Administration, Partner with[company name] to offer workplace retirement plan administration to your clients., 39, 133440000, 1332, [ad_id int], ENABLED, [weburl], , 144, 2022-05-21, RESPONSIVE_SEARCH_AD
We Work W/ Financial Planners, RetirementPlan, Administration, Partner with[company name] to offer workplace retirement plan administration to your clients., 39, 133440000, 1332, [ad_id int], ENABLED, [weburl], , 144, 2022-05-21, RESPONSIVE_SEARCH_AD