CASE
CASE WHEN marks >= 60 THEN 'A' WHEN marks >= 40 THEN 'B' ELSE 'F' END as a column. Simple CASE: CASE grade WHEN 'A' THEN 5 ELSE 0 END. END is required. Works in SELECT, ORDER BY, sometimes UPDATE SET.
More readable than nested IF(). Always ELSE so NULL doesn’t sneak in.
Trap — forgetting END. Trap: overlapping WHEN without noticing order (first match wins).
On the example next to this theory: CASE: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.
Exam tip
CASE WHEN marks >= 40 THEN 'Pass' ELSE 'Fail' END