How to Write a Case Statement in SQL Server
Case statements are useful when you're reaching for an if statement in your select
clause.
select
id,
name,
category,
price,
case
when category = 5 then 'Premium'
when category = 4 then 'Gold'
when category = 3 then 'Standard'
when category <= 2 then 'Basic'
else 'unknown'
end as quality_level
from products;
Previous
How to Have Multiple CountsFinally, a unified workspace for your SQL development
Get more done, together, with PopSQL and SQL Server