Marketing Analytics Path · Mission 5 of 30Starter

What are people buying?

Compute gross AND net revenue per category in one query; learn that `SUM(amount)` already gives you net when refunds are signed.

Back to Marketing Analytics

The Brief

Marcus BellHead of Growthanalytics-help

Can you pull a quick breakdown of purchases by product category? Category name, purchases, total revenue. Sort by revenue so I can see what's making the most money — actually, just sort by revenue desc, I'll eyeball the rest. Heads up: fact_purchases has refunds as negative-amount rows; for "what's making the most money" SUM(amount) gives the right net answer.

You'll practice

SUMGROUP BYRefunds

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

Group `fact_purchases` by `product_category` and use `COUNT(*)` for purchases and `SUM(amount)` for revenue

Hint 2

Filter out refunds first with `WHERE amount > 0` — negative amounts are returns that would skew your totals

Hint 3

Three columns out, with the count and revenue aliased so the result reads cleanly (purchases, total_revenue). Round revenue to 2 decimals. Sort by revenue descending.