Compute gross AND net revenue per category in one query; learn that `SUM(amount)` already gives you net when refunds are signed.
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.
| Column | Type | Key |
|---|---|---|
| purchase_id | INT | PK |
| customer_id | INT | FK → dim_customers |
| purchase_date | TEXT | |
| amount | REAL | |
| product_category | TEXT | |
| campaign_id | INT | FK → dim_campaigns |
| coupon_code | TEXT |
Each hint you reveal reduces the XP you can earn. Try the query first.
Group `fact_purchases` by `product_category` and use `COUNT(*)` for purchases and `SUM(amount)` for revenue
Filter out refunds first with `WHERE amount > 0` — negative amounts are returns that would skew your totals
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.