Revenue by category with a sales threshold
Scenario
You are a data analyst. A grocery chain is deciding which categories get extra shelf space next quarter. Merchandising wants revenue per category, but only categories that actually move.
Question
Show category and total revenue (quantity * unit_price) for categories with revenue above 5000, highest first.
Your task
- Aggregate revenue per category
- Keep only categories above 5000
- Order by revenue descending
Intermediate · Record Counting & Average Calculations — question 11 of 30
1. Choose your dataset
Pick an industry and a size. Your code and results change to match.
💡 Explain my whole code, line by line (hover any word in the editor for a tip)
🌈 In short — no coding words
Altogether: this query reads your industry table, picks what you need, and shows the answer as rows.
Dataset & schema
store_sales
The tiny starter data. Bigger data scrolls.
Fields
| sale_id | category | quantity | unit_price | store |
|---|---|---|---|---|
| 1 | Beverages | 120 | 24.5 | Sandton |
| 2 | Bakery | 300 | 12 | Sandton |
| 3 | Beverages | 210 | 24.5 | Durban |
| 4 | Household | 40 | 89 | Durban |
| 5 | Bakery | 150 | 12 | Cape Town |
$ Press “Check my answer” — results appear here.Your next steps
Each item turns green when your answer includes it.
- Sums revenue
- Groups by category
- Filters aggregate with HAVING
- Orders descending