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.
Author |
Topic |
asksql
Starting Member
11 Posts |
Posted - 2008-06-07 : 03:00:28
|
Hello,I have an if statement for one of my columns in my query.I want to write the if statement as a part of my select statement. How would I do that. Do to a couple of rules I am not allowed to write a stored procedure for this.I could use the "decode function" but I have something like this:if column1 = '1' or column2 = '2' then select "Yes" etc..I tried doing select decode (column1 or column2, , , ) but it doesn't work. Any ideas? |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-07 : 03:22:17
|
SELECT *,CASE WHEN Column1 = '1' OR Column2 = '2' THEN 'Yes'WHEN Column1 = '2' THEN 'Maybe'WHEN Column2 = '1' THEN 'Never'ELSE 'I don't know'ENDFROM Table1 E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|