Marketing Analytics Path · Mission 7 of 30Easy

Which coupon is pulling its weight?

Use GROUP BY with WHERE to filter and aggregate coupon performance

Back to Marketing Analytics

The Brief

Alex ChenMarketing Managerslack-dm

Fyi finance is asking about our coupon codes — can you show me each coupon code, how many times it was used, and the total revenue it drove? No rush, sometime today. Skip the refund rows — they want gross from the redemption side.

You'll practice

GROUP BYWHERENULL filtering

Tables & columns available

fact_purchasesfact7 columns
ColumnTypeKey
purchase_idINTPK
customer_idINTFK → dim_customers
purchase_dateTEXT
amountREAL
product_categoryTEXT
campaign_idINTFK → dim_campaigns
coupon_codeTEXT

Hints (3)

Each hint you reveal reduces the XP you can earn. Try the query first.

Hint 1

Two filters matter here: only rows where a coupon was actually used, and only revenue-positive rows. Remember the briefing wanted zero-dollar trial coupons counted too — that affects how you write the amount filter.

Hint 2

Group by `coupon_code` and compute `COUNT(*) AS times_used` and `SUM(amount) AS total_revenue`

Hint 3

Three columns: coupon code, redemption count, total revenue. Round the revenue, alias it, sort descending so the top performers land first.