Recap - Top Customers
Part of the Beyond the Basics section of Coddy's SQL journey — lesson 27 of 27.
Challenge
MediumAvailable 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_idtotal_spent: sum ofamountpct_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
6Analytics Recipes
Top-N per GroupPercentage of TotalRunning TotalKeeping One Row per KeyRecap - Top Customers