MediumSQL

Top Spending Customers

SQLDatabases

Write a SQL query that finds all customers whose **total order amount exceeds
$200**, ordered by total amount descending.

Table: `orders`

idcustomeramount
1Alice120
2Bob80
3Alice200
4Carol150
5Bob90
6Alice75
7Carol60

Alice total = 395, Carol total = 210, Bob total = 170.

Expected output (columns: customer, total)

Alice|395
Carol|210

SQLite output format — rows are pipe-separated (|) with no column headers.

Example: SELECT id, name FROM users WHERE id = 11|Alice

Sample tests

Test #1Alice (395) and Carol (210) exceed 200; Bob (170) does not
Input: "CREATE TABLE orders (id INTEGER, customer TEXT, amount INTEGER);\nINSERT INTO orders VALUES\n (1, 'Alice', 120), (2, 'Bob', 80), (3, 'Alice', 200),\n (4, 'Carol', 150), (5, 'Bob', 90), (6, 'Alice', 75), (7, 'Carol', 60);"
Output: "Alice|395\nCarol|210"