Iris, a consumer electronics brand, would like to modify a query to only include purchase records from the underlying table. Which of the following represents how the query should be written?
Choose an answer
Tap an option to check your answer.
Correct answer: 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.
Why this is the answer
The correct query filters the amazonattributedeventsbytraffictime table using WHERE purchases = 1. This condition specifically selects records where a purchase occurred, fulfilling the requirement to include only purchase records. The GROUP BY 1 aggregates the results by campaign, and COUNT(DISTINCT userid) and SUM(purchases) calculate the number of unique purchasers and total purchases for each campaign, respectively. The second incorrect option uses FROM conversions, which is a different table and may not contain the necessary purchases column or the desired data structure. The third incorrect option uses FROM amazonattributedeventsbytraffictime but lacks the WHERE purchases = 1 clause, meaning it would include all records from the table, not just purchase records.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed