November 8, 2007 at 5:21 pm
Is it possible to have multiple "when" parameters for one "then" statement? For example:
Case ActionType
When 'TMA' or 'TMB' or 'TMC'
Then 12345
OR
Case ActionType
When 'TM%'
Then 12345
I know I can do it with multiple statements:
Case ActionType
When 'TMA'
Then 12345
When 'TMB'
Then 12345
When 'TMC'
Then 12345
but that will be very unweildly.
Any thoughts? Thanks
November 8, 2007 at 5:37 pm
You can do:
Select
Case
When ActionType in ('TMA','TMB','TMC') Then 12345
When ActionType in ('TMD','TME','TMF') Then 54321
Else 0
End
November 9, 2007 at 8:14 am
Thanks, you are a life saver. Thanks for helping a nube struggling with simple things.
Your solution worked great!
November 9, 2007 at 8:22 am
Ummm... rather than struggling with syntax, do you know what Books Online is? Comes free with SQL Server and, although it sometimes takes a bit to find what you're looking for, has great examples for things like CASE...
--Jeff Moden
Change is inevitable... Change for the better is not.
November 9, 2007 at 9:07 am
I will take a look - thanks.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply