Blog · Guide
SQL CASE WHEN Explained: If/Then Inside a Query
CASE WHEN builds categories in SQL — age bands, status flags, custom labels — without leaving the SELECT.
Inline if/else for columns
SELECT first_name, age, CASE WHEN age < 30 THEN 'under_30' WHEN age < 40 THEN 'thirties' ELSE '40_plus' END AS age_band FROM customers;
Conditions are checked top to bottom; first match wins.
Try it yourself
The fastest way to lock this in is a short drill on the same Northstar Market tables.