Home » Amazon Marketing Cloud » 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?

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?

  • SELECT campaign, COUNT(DISTINCT user_id) AS purchasers, SUM(purchases) AS purchases FROM conversions GROUP BY 1
  • 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

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

Explanation: To modify a query to only include purchase records from the underlying table in AMC, you should filter for purchase events using a WHERE purchases = 1 clause. The canonical query to achieve this 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

This query counts the number of unique purchasers and total purchases for each campaign, filtered to records where a purchase event occurred.

Reference content:

“Sponsored Products and Sponsored Display uses amazon_attributed_events_by_traffic_time… Querying for purchase events requires filtering the purchases column to 1.”

(Amazon Marketing Cloud data sources overview)

N/A

Leave a Comment