I have an example table(#temp) like:
Account ABC DEF GHI
-----------------------------------
A001 1000.00 NULL NULL
A002 NULL 500.00 800.00
A003 NULL 700.00 NULL
A004 1100.00 NULL NULL
The headers ABC, DEF, GHI are the result of a pivot. I'd like to:
select
*,
case
when ABC is not NULL and JKL is not NULL
then 1
else 0
end as newColumn
from
#temp
This errors out, because JKL doesn't exist. However, it can exist and has to be accounted for when it does. How can I edit my query statement to check if the columns ABC and JKL exist > if they do not exist then 0 value > if they do exist and either are null then 0 value > if they are both not null then 1 value in a newColumn.
JKL, even if it isn't needed?