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 2012 Forums
 Transact-SQL (2012)
 Help with SELECT CASE

Author  Topic 

fralo
Posting Yak Master

161 Posts

Posted - 2014-01-17 : 11:37:21
Hi,

Let's suppose that I query a couple of columns from a table:

select name, code from table

I want the value of name to return as blank if the value of code is one of many values (i.e. 10, 20, 30), otherwise display its true value. Is this possible with SELECT CASE?

Thank you.

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2014-01-17 : 12:43:31
[code]SELECT
CASE
WHEN Code IN (10, 20, 30) THEN ''
ELSE Name
END AS Name,
Code
FROM
TableName
[/code]
Go to Top of Page
   

- Advertisement -