Marketing Analytics Path · Mission 5 of 25Starter

What are people buying?

Use GROUP BY with SUM to aggregate revenue by category

Back to Marketing Analytics

The Brief

Marcus BellHead of Growthanalytics-help

Can you pull a quick breakdown of purchases by product category? I need the category name, number of purchases, and total revenue for each. Sort by revenue so I can see what's making the most money.

You'll practice

SUMGROUP BYRefunds

Tables available

fact_purchases

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

Alias your columns: `COUNT(*) AS purchases, ROUND(SUM(amount)::numeric, 2) AS total_revenue` and sort by revenue DESC