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 2000 Forums
 Transact-SQL (2000)
 Possible?

Author  Topic 

Revoked
Starting Member

1 Post

Posted - 2002-10-24 : 15:42:37
okay is it possible to do something like this:

SELECT IF(<condition>,myColumn1,myColumn2) FROM myTable

if <condition> = true then I basically have:

SELECT mycolumn1 FROM myTable

if <condition> = false then:

SELECT myColumn2 FROM myTable


is this possible at all?? I thought I saw something that did it a while back but I can't remember.


robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-10-24 : 15:45:35
SELECT CASE WHEN A=1
THEN mycolumn1
ELSE mycolumn2
END
FROM myTable


You can read more about CASE in Books Online and in these articles:

http://www.sqlteam.com/SearchResults.asp?SearchTerms=case

Go to Top of Page
   

- Advertisement -