Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Problem with CASE WHEN statement - response (11) by atomhouse

$
0
0

Hi,
     I am facing an issue with the CASE statements. Please find below the case statement,
 
CASE
WHEN TYPE_CD IN ('01','02','03') THEN 1
WHEN TYPE_cD IN ('03') AND STS_CD='N' THEN 0
ELSE 0
END as CNT
 
here, CNT is always assigned as '1', even if the TYPE_CD=03 and STS_CD='N'.. If the first CASE statement is executed, will the second statement not execute?
I tried changing the sequence of the case statements like,
CASE
WHEN TYPE_cD IN ('03') AND STS_CD='N' THEN 0
WHEN TYPE_CD IN ('01','02','03') THEN 1
ELSE 0
END as CNT
 
Then, the record with TYPE_CD=03 and STS_CD='N' is assigned 0 as CNT.
Can someone help me understand this?
 
Regards,
 
Anu
 
 
 
 
 


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>