How do I add a where clause <> 0 for case statement in postgresql?

56 Views Asked by At

I have a case statement where I am trying to add a where clause <> 0 for the case statement . However, I am not able to do as the error is saying the column name is not existed. This is the current code:

SELECT *,

CASE 
when A.TestValue is null then 
B.Collected
when B.Collected is null then 
A.TestValue
END
as Actual_Value 

FROM test_Table
where Actual_Value <> 0
1

There are 1 best solutions below

0
Sriram On
CASE 
when A.TestValue is null then B.Collected 
when B.Collected is null then A.TestValue 
END <> 0