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
 Help with If Then/case if statement

Author  Topic 

Cooperrud
Starting Member

1 Post

Posted - 2015-03-23 : 14:09:50
So, I am stumped on how this would work. Not sure if a 'case if' is necessary or not. But essentially, I have a column that contains the values A or B and another column that contains a "status date" an a third and final column that contains "established date".

In my output, I need the "status date" if my value is A, and if my value is B I need the "established date". I've tried a case if, but I don't think I'm doing it right. Any Ideas?

Thanks in advance!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2015-03-23 : 14:14:45
SELECT SomeAlias = CASE WHEN acolumn = 'A' THEN AnotherColumn WHEN acolumn = 'B' THEN FinalColumn END
...

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -