Practice · medium · dataset: ecom
Revenue per customer by country
For each country, report the number of distinct customers who ordered, total revenue, and revenue
per ordering customer. Revenue is quantity times the line’s unit_price.
Return country, customers, revenue, and revenue_per_customer, with money columns rounded to
two decimals. Sort by revenue descending, then by country 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 |
customers counts distinct customers with at least one order, not the number of orders or line
items.
⌘/Ctrl + Enter to grade
Write a query, then grade it.
Hints
Try it first. Reveal a hint only when you are stuck.