Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 CASE statement with multiple columns/variables

Author  Topic 

greg6363
Starting Member

1 Post

Posted - 2012-03-14 : 17:41:56
(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.






greg6363

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2012-03-14 : 17:58:47
Your issue seems to be only syntax. The IN operator syntax requires parentheses around the list (e.g., "WHEN LoanStatus in ('01') then 'In Grace'"). Also, is there a reason you are not using an equality test instead of the IN operator?

=================================================
Men shout to avoid listening to one another. -Miguel de Unamuno
Go to Top of Page
   

- Advertisement -