← All SQL interview questions

Customers who out-spend the average customer

MediumSubqueriesMeeshoMyntra

The loyalty team wants to reward customers whose total spend is above the average total spend of all customers.

From purchases, return customer_name and total_spent for every customer whose total spend is greater than the average of all customer totals. Show the biggest spender first.

Sample data

Table: purchases

15 row(s) · showing first 8

purchase_idINTcustomer_nameTEXTamountNUMERIC(10,2)
1Anil1200.00
2Anil3400.00
3Bela800.00
4Bela650.00
5Chetan5200.00
6Chetan4100.00
7Deepa1500.00
8Deepa2200.00