Practice · Economy · Medium

Label the inflation years (CASE)

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.

What you are given

Use a CASE WHEN … THEN … expression. The first matching branch wins.

Starting point

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.

Did you know

CASE is SQL’s if/else — it turns raw numbers into human-readable categories right in the query. (SQLite docs)

More Economy challenges

Open it in the playground →