Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to put conditional where clauses?
Message
From
17/12/2007 14:50:16
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01276215
Message ID:
01276307
Views:
19
Sorry Sergey, but i wasn't at home when you reply.

But you helped a lot, after your answer i tried different forms of case in the where clause and finally i got it.

Before i got an error message, saying that the syntax was incorrect, i assumed it had to do with the 'case' but that wasn't the case...

Thank you,
Joaquim

>Sure you can use CASE function in the WHERE clause. What seems to be a problem? Can you post real query?
>
>>
>>I need a sql querie that returns some rows like this:
>>
>>select a.id, a.name, a.type, a.type1, a.type2, a.selection
>where a.type = (case a.selection = '1' a.type1 else b.type2 end)
>>
>>or
>>
>>select a.id, a.name, a.type, a.type1, a.type2, a.selection
>where a.type = iif(a.selection = '1', a.type1, b.type2)
>>
>>I know thar 'iif' is not permited in Sqlsrvr, on the other hand it seems that i can't use 'case else end' in a where condition, so how to acomplish a mission like this?
>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform