Menu
Coddy logo textTech

Recap - Top Customers

Part of the Beyond the Basics section of Coddy's SQL journey — lesson 27 of 27.

challenge icon

Challenge

Medium

Available tables and columns:

  • <strong>orders</strong>: <strong>id</strong>, <strong>customer_id</strong>, <strong>amount</strong>, <strong>status</strong>

Considering only orders with status = 'paid', return for each customer_id:

  • customer_id
  • total_spent: sum of amount
  • pct_of_revenue: that customer's share of total paid revenue, rounded to 1 decimal place

Order by total_spent descending.

Try it yourself

-- aggregate paid orders per customer; compute pct of total

All lessons in Beyond the Basics