Practice · medium · dataset: ecom
Category revenue by country
For each country and product category that has sales, report total revenue from line items. Revenue
is quantity times the line’s unit_price.
Return country, category, and revenue rounded to two decimals. Sort by country ascending,
then by revenue descending, then by category ascending.
Tables available
| Table | Columns |
|---|---|
customers |
customer_id, email, country, signup_date |
orders |
order_id, customer_id, order_date, status, channel |
order_items |
order_id, product_id, quantity, unit_price |
products |
product_id, name, category, unit_price |
Only pairs that actually have sales should appear; there is no need to generate an empty country-category combination.
⌘/Ctrl + Enter to grade
Write a query, then grade it.
Hints
Try it first. Reveal a hint only when you are stuck.