Back to Practice
#0352
Pivot Status Counts With CASE
MediumSQL24 min20 XP
Problem
Return paid_orders, pending_orders, and cancelled_orders as one row.
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
Input2 paid, 1 pending, 1 cancelled
Output2, 1, 1
Each CASE expression counts one status bucket.
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
Input2 paid, 1 pending, 1 cancelled
Expected[[2,1,1]]
Each CASE expression counts one status bucket.
Hidden Test Categories
Empty or missing matchesDuplicate rows or tiesNULL values where the pattern commonly breaks