Labels with CASE WHEN
CASE WHEN is SQL's version of a spreadsheet IF. It works out a value for each row:
SELECT name, list_price,
CASE
WHEN list_price < 5 THEN 'Budget'
WHEN list_price < 20 THEN 'Standard'
ELSE 'Premium'
END AS price_band
FROM productsThe conditions are checked in order and the first true one wins, so a £3 product is 'Budget' even
though it's also under £20. ELSE catches everything else; without it, unmatched rows get NULL.
Always finish with END, and give the result a name with AS.