Hard
HAVING

Customers Spending Above 500

Find customers whose total completed-order spend exceeds 500. Return columns: customer_name, total_spend. Order results by: total_spend DESC, customer_name.

Preparing the interactive SQL workspace...

Challenge overview

What you will practice

Find customers whose total completed-order spend exceeds 500. Return columns: customer_name, total_spend. Order results by: total_spend DESC, customer_name.

Difficulty
Advanced
SQL concept
HAVING

Public schema and sample data

customers

id INTEGERname TEXTemail TEXTcountry TEXTjoined_date TEXT
1Acme Corpacme@corp.comUSA2020-01-15
2TechStart Ltdts@techstart.ioUK2020-03-22
3DataFlow Incinfo@dataflow.comUSA2021-06-10

products

id INTEGERname TEXTcategory TEXTprice REALstock INTEGER
1Analytics DashboardSoftware299999
2Data WarehouseInfrastructure149950
3ML PipelineSoftware799999

orders

id INTEGERcustomer_id INTEGERorder_date TEXTtotal_amount REALstatus TEXT
112024-01-102697completed
222024-01-15799completed
312024-02-011499completed

order_items

id INTEGERorder_id INTEGERproduct_id INTEGERquantity INTEGERunit_price REAL
1113299
214899
3231799