I have a case statement, which returns null values in a column whereas I dont want the null values when executing the case statement.
SELECT ABC
(
CASE
WHEN
condition
THEN 1
WHEN
condition2
THEN 2
END
) AS column_name FROM tablename;
Column_name returns null values as well
So I changed the query to
SELECT ABC
(
CASE
WHEN
condition
THEN 1
WHEN
condition2
THEN 2
else 3
END
) AS column_name FROM tablename where column_name <>3;
I get an error ‘invalid identifier’.
Any thoughts on this?
You are missing a comma after
ABC(assuming thatABCis a column):You can also remove those parentheses, not needed really.
It’s not clear why you added that
WHERE column_name <> 3. Your adjustedCASEturned thoseNULLinto3. Do you want to show those rows or not? If yes, keep the query as above. If not, you could use this:or (that’s closer to your logic):