Back to Practice
#0323

Bucket Orders by Amount

EasySQL15 min10 XP

Problem

Return order_id and size_bucket: small for amount < 50, medium for amount < 100, otherwise large.

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, amount INTEGER)

Examples

Example 1
Inputamounts 30, 75, 120
Outputsmall, medium, large

CASE conditions are evaluated from top to bottom.

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
Inputamounts 30, 75, 120
Expected[[1,"small"],[2,"medium"],[3,"large"]]

CASE conditions are evaluated from top to bottom.

Hidden Test Categories
Empty or missing matchesDuplicate rows or tiesNULL values where the pattern commonly breaks