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
 Output

Author  Topic 

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2012-03-12 : 03:03:27
Name Age ClassCode
May 10 A23
Jane 12 A40
John 12 A40
Kim 11 A40

I would like to select all data.
But only give the output which class code = A40.
If class code is not A40, just leave it blank.
Can I do that?

The result should be like this:

Name Age ClassCode
May 10
Jane 12 A40
John 12 A40
Kim 11 A40

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-03-12 : 04:10:49
[code]
select Name, Age, ClassCode = case when ClassCode = 'A40' then ClassCode else '' end
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-12 : 10:01:09
looks like a presentation requirement to me

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

Go to Top of Page
   

- Advertisement -