Practice · Economy · Medium
For each year, return year, rate_pct, and a band: ‘Low’ if under 10, ‘Moderate’ if under 25, otherwise ‘High’. Oldest year first.
Runs in your browser. No signup needed.
Use a CASE WHEN … THEN … expression. The first matching branch wins.
SELECT year, rate_pct,
CASE WHEN rate_pct < 10 THEN 'Low'
WHEN rate_pct < 25 THEN 'Moderate'
ELSE 'High' END AS band
FROM inflation
ORDER BY year;
The reference solution is checked automatically when you run your query on the practice page — results are compared row by row, and order matters for this one.
CASE is SQL’s if/else — it turns raw numbers into human-readable categories right in the query. (SQLite docs)