Skip to content

Instantly share code, notes, and snippets.

@sqlparser
Created April 8, 2014 07:13
Show Gist options
  • Save sqlparser/10098931 to your computer and use it in GitHub Desktop.
Save sqlparser/10098931 to your computer and use it in GitHub Desktop.
case expression
SELECT productnumber,
name,
'Price Range' = CASE
WHEN listprice = 0 THEN 'Mfg item - not for resale'
WHEN listprice < 50 THEN 'Under $50'
WHEN listprice >= 50
AND listprice < 250 THEN 'Under $250'
WHEN listprice >= 250
AND listprice < 1000 THEN 'Under $1000'
ELSE 'Over $1000'
END
FROM production.product
ORDER BY productnumber;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment