Practice · medium · dataset: ecom

Customers above average spend

Find customers whose total spend exceeds the average total spend across customers who have ordered. Spend is the sum of quantity times line unit_price across all of a customer’s orders.

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

Customers with no orders are outside the population used for the average, so they cannot appear in the result.

⌘/Ctrl + Enter to grade

Write a query, then grade it.

Hints

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