CASE WHEN - Conditional Logic
CASE WHEN adds if/else logic directly in your SQL queries.
Structure:
CASE
WHEN condition THEN result
WHEN condition THEN result
ELSE default_result
ENDExample - categorize salaries:
CASE WHEN is incredibly powerful for creating categories, labels, and conditional calculations right in your query.
Check your understanding
Use CASE WHEN to label salaries as 'High' or 'Standard'.
Examples run on the employees sample database. Open any of them in the playground to experiment.