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 2005 Forums
 Transact-SQL (2005)
 case with list ?

Author  Topic 

BitShift
Yak Posting Veteran

98 Posts

Posted - 2007-10-30 : 17:08:07
Can I do something like the following or is there a better way ?


CASE some_column
when some_column in ('A','B','C',) THEN (some_other_column * colA)/4
END CASE

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-10-30 : 17:13:35
should be fine. Except for the additional 'CASE' after the END.


quote:
Originally posted by BitShift

Can I do something like the following or is there a better way ?


CASE some_column
when some_column in ('A','B','C',) THEN (some_other_column * colA)/4
END CASE As [SomeColumn]





Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-30 : 17:21:34
quote:
Originally posted by BitShift

Can I do something like the following or is there a better way ?


CASE some_column
when some_column in ('A','B','C',) THEN (some_other_column * colA)/4
END CASE






E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-31 : 02:25:35
Also if all the columns are of INT datatype you need to use 4.0 to get correct answer

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -