All Forums Database
greg6363 1 post Joined 03/12
14 Mar 2012
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.

 

ulrich 816 posts Joined 09/09
15 Mar 2012

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'

feel free to donate bitcoin:12kgAUHFUqvG2sQgaRBXFhCwyf9HXdkGud

You must sign in to leave a comment.