The Case statement with if clause
If REC_STAT_CD in ('B' , 'J')
if ACB_CD in (NA, A, B,C, D, Z,V,W,X,Y,S) or CONS_INF_IND in (NA, A, B,C, D, Z,V,W,X,Y,S)
Then 'Active'
Else 'Disch'
endif
Else (not B and not J)
'None'
endif
Table are Table XYZ. My query is as below:
select
CASE WHEN REC_STAT_CD in ('B','J') then
CASE when ACB_CD in ('NA', 'A', 'B','C', 'D', 'Z','V','W','X','Y','S') or CONS_INF_IND in ('NA', 'A', 'B','C', 'D', 'Z','V','W','Y','S')
then 'Active' else 'Disch'
END)
END)
CASE when REC_STAT_CD not in ('B','J') then 'None'
END)
from LDS.XYZ
My query works fine if I remove the 2nd case statement , but I am not sure how else can i put the clauses in the query. I need the entire output for one column REC_STAT_CD. Please provide inputs , any help truly appreciated.