Back to Practice
#0314
Count Orders Per Status
EasySQL15 min10 XP
Problem
Return status and order_count for each status, ordered by status.
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, status TEXT)
Examples
Example 1
Inputorders grouped by status
Outputone row per status
GROUP BY status creates a group for each status value.
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
Inputorders grouped by status
Expected[["cancelled",1],["paid",2],["pending",1]]
GROUP BY status creates a group for each status value.
Hidden Test Categories
Empty or missing matchesDuplicate rows or tiesNULL values where the pattern commonly breaks