Case statements are useful when you're dealing with multiple IF statements in your select clause. It comes in two forms:
WHEN score < 70 THEN 'failed'
WHEN score BETWEEN 70 AND 80 THEN 'passed'
WHEN score BETWEEN 81 AND 90 THEN 'very good'
END AS performance
WHEN 'A' THEN 'Excellent'
WHEN 'B' THEN 'Good'
WHEN 'C' THEN 'Needs Improvement'
END AS grade_interpretation
Spread the word