Should I include an ELSE in a CASE expression?
For example, if I wanted to output the names of animals that are cats and nothing ELSE, can I use this SELECT :
SELECT DISTINCT(CASE WHEN animal_type = 'cat' THEN animal_name END) AS cat_names
I know that I can just put animal_type = 'cat' in my WHERE and then
SELECT DISTINCT cat_names,
but I would like to know the answer.
source share