CASE Statement with multiple columns/variables

Database

CASE Statement with multiple columns/variables

(CASE

WHEN WX-LON-SUB-STA in 'Deferment' then 'In Deferment'

WHEN WX-LON-SUB-STA in 'Forbearance' then 'Forbearance'

WHEN LoanStatus in '01' then 'In Grace'

WHEN LoanStatus in '02' then 'In School'

WHEN DaysDelinquent > 0 then 'In Repayment'

ELSE ' ' END) as Status

I am running a program in Microsoft SQL Server Management Studio 2008

and I need to create a column called Status which will populate 5

values from 3 separate variables (WX-LON-SUB-STA, LoanStatus,

DaysDelinquent).  Is there any way to create a nested case statement

with the code that I have enclosed in this message?  Any assistance

would be greatly appreciated.  Thanks.


1 REPLY
Senior Supporter

Re: CASE Statement with multiple columns/variables

if you use in you need to enclose the list - even if it is one with ()

WHEN WX-LON-SUB-STA in ('Deferment')

or use 

WHEN WX-LON-SUB-STA = 'Deferment'