CASE: conditions inside SELECT
Lesson 19 of 24 · SQL.Micro
CASE works like an if/else that produces a value for each row. Use it to label, bucket or translate data.
CASE WHEN minutes < 100 THEN 'short' ELSE 'long' END
The first true WHEN wins; ELSE covers everything else.
A row matches none of the WHENs and there is no ELSE. The result is…
For every movie, show the title and the label 'short' if it runs under 100 minutes, otherwise 'long'.
Do it in the browser: a real SQL tool, a short mission and instant feedback. No install.
Start this lesson — free