Practice · easy · dataset: ecom

Top customers by revenue

Sales wants the five customers who generated the most revenue from their order line items. Revenue for a line is quantity times the line’s unit_price.

Return customer_id, email, and revenue rounded to two decimals. Sort by revenue descending, then by customer_id 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

Use the unit_price stored on the line item, not the product’s current price. Include every line item regardless of the parent order’s status.

⌘/Ctrl + Enter to grade

Write a query, then grade it.

Hints

Try it first. Reveal a hint only when you are stuck.