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
 General SQL Server Forums
 New to SQL Server Programming
 Case Select Limits

Author  Topic 

matta0990
Starting Member

44 Posts

Posted - 2011-08-31 : 04:14:50
Hi, is there any way of over riding case select limits?

I have a nested case select for 11 but my limit is 10. I need the qurey to display the field results numbered so i can put them in order.

e.g-- this is my case select-- if there is a better way of doing this, please advice


Case When C.Account_Line_Type = 'OpeningBalance' Then 1 Else
(case when c.Account_Line_Type = 'PriorAdjustment' then 2 else
(case when c.Account_Line_Type = 'InterimBalance1' then 3 else
(case when c.Account_Line_Type = 'TotalReceipts' then 4 else
(case when c.Account_Line_Type = 'InterimBalance2' then 5 else
(case when c.Account_Line_Type = 'TotalSales' then 6 else
(case when c.Account_Line_Type = 'TotalTransfers' then 7 else
(case when c.Account_Line_Type = 'InterimBalance3' then 8 else
(case when c.Account_Line_Type = 'InterimBalance4' then 9 else
(case when c.Account_Line_Type = 'TotalConsumption' then 10 else
(case when c.Account_Line_Type = 'InterimBalance4' then 11 else 0 end) end) end) end) end) end) end) end) end) end) end as OrderNumber

J Smith

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-31 : 04:19:46
instead of all these nested case expressions why cant put the values alone with types in a mapping table? that way the above series of case expressions would reduce to a single join with table on
C.Account_Line_Type = table.TypeValue and it will be scalable also
ie any new type addition just requires adding a new value to your mapping table rather than opening and adding new case expression inside each of code snippet which uses it

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

matta0990
Starting Member

44 Posts

Posted - 2011-08-31 : 04:38:42
Thank you, Ive got it working using temp table

J Smith
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-31 : 04:39:47
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -