Skip to main content
πŸ—„οΈ SQL Projects

Top Customers

What you're building

A leaderboard of customers ranked by how much they've spent β€” used in CRM dashboards, loyalty programs, and churn analysis.

Requirements

Join orders, products, and customers. Return:

  • name β€” customer name
  • total_spent β€” total money spent (price Γ— quantity summed)
  • order_count β€” number of orders placed

Order by total_spent descending. Include all customers who placed at least one order.

Tables: customers(id, name, city) Β· orders(id, customer_id, product_id, quantity) Β· products(id, price)

Stretch goals

  • Show only the top 3 with LIMIT 3.
  • Add city to the output so you can see geographic patterns.

What this proves

Multi-table joins, aggregation, and ranking β€” the exact triad tested in SQL screens at every tech company.

⚑ 40 XP
query.sqlRuns in your browser (SQLite/WASM)
Loading editor…
Tests1 to pass
Customers ranked by total spend

Run your code to check these.