LogiQuest

506. Total Spent per Customer

MediumJOINGROUP BYSUM

Return each customer's name and the total amount of their orders as total_spent, only for customers who ordered, highest total first.

customers

idnamecity
1AnilDelhi
2BinaChennai
3ChetanDelhi
4DivyaKolkata
5EshaChennai

orders

idcustomer_idamountorder_date
115002024-01-05
217002024-02-10
322002024-01-20
4315002024-03-01
528002024-03-15
613002024-03-20
7510002024-02-01

Your query runs on a fresh copy of these tables (SQLite). Column names in your result do not need to match.

Loading the MyLoginn IDE…