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
 Adding one more condition to the Case

Author  Topic 

sqlbug
Posting Yak Master

201 Posts

Posted - 2010-03-22 : 16:27:48
I have this procedure where I am using a Case statement like:

SELECT...
CASE Sample_Time
WHEN '0' THEN '1'
WHEN '100' THEN '2'
.....and so on

I need to add an additional condition here so if the value of a variable - @Sample_Type <> '1' , then Sample_Time = 'n/a'...instead of one of those 1, 2, 3..24 values it gets from the Case statement.

Any ideas how I can do it?
Thanks,

sqlbug

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-03-22 : 16:53:29
[code]SELECT
case when @Sample_Type <> '1' then 'n/a' else
CASE Sample_Time
WHEN '0' THEN '1'
WHEN '100' THEN '2'...
END
end as [urcolumn][/code]
Go to Top of Page

sqlbug
Posting Yak Master

201 Posts

Posted - 2010-03-22 : 17:20:03
Thanks vijay..
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-03-22 : 17:57:04
np..you're welcome.
Go to Top of Page
   

- Advertisement -