I’m trying to return one value for two conditions in SQL CASE
statement
CASE
WHEN Col1 = 'false' OR Col1 IS NULL THEN 'NA'
ELSE ...
END
Data
Col1
-----
false
poor
moderate
null
In the query result, I’m getting two times "NA" repeatedly.
I’m expecting a one-time "NA"
Output
Col1
-----
NA
poor
moderate
NA
Expected Output:
Col1
-----
NA
poor
moderate
2
Answers
UNION where first select picks NA and second select picks the others
UNION comes with and implied distinct so the outcome is
So you want
DISTINCT
results?With a simplified
CASE
expression, too. See: