How would you adapt this query to obtain cost and impression metrics by supply_source? SELECT device_type, operating_system, SUM(total_cost)/100000 AS total_cost_dollars, ((SUM(total_cost)/100000)/SUM(impressions))*1000 AS avg_cpm, SUM(impressions) AS impressions FROM dsp_impressions GROUP BY 1,2
- SELECT supply_source, SUM(total_cost)/100000000 AS total_cost_dollars, ((SUM(total_cost)/100000000)/SUM(impressions))*1000 AS avg_cpm, SUM(impressions) AS impressions FROM dsp_inventory GROUP BY 1
- SELECT supply_source, SUM(total_cost)/100000 AS total_cost_dollars, ((SUM(total_cost)/100000)/SUM(impressions))*1000 AS avg_cpm, SUM(impressions) AS impressions FROM dsp_impressions GROUP BY 1,2
- SELECT supply_source, SUM(total_cost)/100000 AS total_cost_dollars, ((SUM(total_cost)/100000)/SUM(impressions))*1000 AS avg_cpm, SUM(impressions) AS impressions FROM dsp_impressions GROUP BY 1
Explanation:
The correct answer is **SELECT supply_source, SUM(total_cost)/100000 AS total_cost_dollars, ((SUM(total_cost)/100000)/SUM(impressions))*1000 AS avg_cpm, SUM(impressions) AS impressions FROM dsp_impressions GROUP BY 1** because this query correctly adapts the original query to obtain cost and impression metrics by **supply_source**. In this adjusted query, the **supply_source** field is added in both the SELECT and GROUP BY clauses to group the results by the specific supply source, which allows you to see the total cost, average CPM, and impressions broken down by supply source. The query uses **dsp_impressions** as the data source, which contains the relevant metrics. The other options either reference incorrect tables, such as **dsp_inventory**, or do not properly include the necessary grouping for supply source. This version correctly calculates the metrics by supply source, ensuring the results align with the user’s objective.