Chapter 4 · Aggregations
56. Total Revenue Per Customer with Name
Medium20 XPE-Commerce
Calculate the total revenue generated by each customer. Join orders with customers to show the customer's full name (first_name || ' ' || last_name), their total number of orders, and their total spending. Only include customers who have spent more than 500 in total. Sort by total spending descending.
Tables
- PKidINT
- first_nameTEXT
- last_nameTEXT
- emailTEXT
- phoneTEXT
- cityTEXT
- stateTEXT
- countryTEXT
- created_atTIMESTAMP
- PKidINT
- FKcustomer_id→ customers.idINT
- order_dateTEXT
- statusTEXT
- total_amountREAL
Need help?
Ask Sol
AI tutor — looks at your current query and nudges you, without spoiling the answer.
Solution
Try the hints first — solving it yourself is what makes it stick.