Customer Value Report

Business problem: management wants a report of every customer who has generated over £100 in total revenue (via order_items and products), to prioritise them for a loyalty programme review.

What data is needed: each customer's total spend, computed from every line item across every one of their orders. How tables relate: customers → orders → order_items → products (a four-table join). Write a query returning each qualifying customer's name and total spend, sorted highest first. Verify: manually check the highest spender's total against their individual order_items rows before trusting the report.

query.sql
Loading editor…

Test cases

  • Full result: qualifying customers by total spend, highest first
  • Returns exactly three qualifying customers

Use Run to explore freely against the sample database. Use Submit to grade your query against every test case, including any hidden ones.