Label values with CASE
Turn a score into a readable label with a searched CASE expression.
What you are trying to do
A tutor wants a simple review list that marks scores of 80 or more as Pass.
Work through it
- Read the WHEN condition and its boundary value.
- Evaluate the condition for each score.
- Check the label produced by THEN or ELSE.
Check your work
The rows are 72 Review, 80 Pass, and 91 Pass. The score 80 meets the inclusive boundary.
Practice SQL
Open in SQL FlowSELECT Score, CASE WHEN Score >= 80 THEN N'Pass' ELSE N'Review' END AS Outcome
FROM (VALUES (72), (80), (91)) AS Assessment(Score)
ORDER BY Score;
Knowledge check
Commands in this lesson
Next lesson Combine filters with AND and OR