Which of these queries will only include purchase records from the underlying table?
- SELECT campaign, COUNT(DISTINCT user_id) AS purchasers, SUM(purchases) AS purchases FROM amazon_attributed_events_by_traffic_time GROUP BY 1
- SELECT campaign, COUNT(DISTINCT user_id) AS purchasers, SUM(purchases) AS purchases FROM amazon_attributed_events_by_traffic_time WHERE purchases = 1 GROUP BY 1
- SELECT campaign, COUNT(DISTINCT user_id) AS purchasers, SUM(purchases) AS purchases FROM conversions GROUP BY 1
Explanation: The correct answer is **SELECT campaign, COUNT(DISTINCT user_id) AS purchasers, SUM(purchases) AS purchases FROM amazon_attributed_events_by_traffic_time WHERE purchases = 1 GROUP BY 1** because the query includes a **WHERE purchases = 1** condition, which filters the results to only include records where a purchase event has occurred. This ensures that only purchase records are included in the query output. By using the condition purchases = 1, the query focuses specifically on instances where a purchase has been made, excluding other event types such as impressions or clicks. The other queries do not have a specific condition to filter out non-purchase events, meaning they would include all types of events, not just purchases.