Statement
medium
Top customers by total
`top_customers(conn, limit=3)` returns a list of dicts
`{"customer": str, "total": number}` — the customers with the highest order
totals.
Table schema:
```sql
CREATE TABLE orders (customer TEXT, amount REAL)
```
Requirements:
- the total sums all orders of a customer;
- sorted by total descending;
- `limit` is applied;
- an empty table returns an empty list.
Write tests against `sqlite3.connect(":memory:")`.
AI mentor
The AI mentor is available after you log in: it sees your attempt history and does not spend resources on anonymous requests.
Log in and ask
Hints
1 of 3 unlocked · attempts: 0
Hint 1
What exactly does each test check: the order, the total, or the number of rows? Do
not mix them — otherwise it is unclear which break was caught.
Hint 2 — unlocks after 1 attempt
Hint 3 — unlocks after 3 attempts