Back to Practice
#0355
WHERE Before GROUP BY
EasySQL15 min10 XP
Problem
For paid orders only, return customer_id and paid_revenue.
Why This Matters
SQL interviews usually test whether you can turn a business question into the right rows, grouping level, join type, and edge-case behavior.
Schema
orders(order_id INTEGER, customer_id INTEGER, status TEXT, amount INTEGER)
Examples
Example 1
Inputcancelled order should not count
Outputcustomer 1 paid revenue 40
WHERE removes cancelled rows before SUM is calculated.
Constraints
- Return only the requested columns.
- Use deterministic ORDER BY when multiple rows are returned.
- Assume SQLite-compatible SQL unless the prompt states otherwise.
CodeSQL
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Core SQL case
Inputcancelled order should not count
Expected[[1,40],[2,20]]
WHERE removes cancelled rows before SUM is calculated.
Hidden Test Categories
Empty or missing matchesDuplicate rows or tiesNULL values where the pattern commonly breaks