Is there a condensed form of the following statement?
SELECT Name, Case StatusID WHEN 1 THEN 'Alive' WHEN 2 THEN 'Alive' WHEN 3 THEN 'Alive' WHEN 4 THEN 'Dying' ELSE 'Dead' END FROM People
for example
CASE StatusID WHEN 1,2,3 THEN 'Alive'
or
CASE StatusID WHEN 1 OR 2 OR 3 THEN 'Alive'
depending on the DB you use the following will do the trick
SELECT
Name,
Case WHEN StatusID IN ( 1, 2, 3 ) THEN 'Alive' WHEN StatusID = 4 THEN 'Dying' ELSE 'Dead' END
FROM People
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With