Reputation: 31
Is there any way to use if-else logic in where clause in T-SQL? or do I have to implement the logic by using subquery?
Upvotes: 3
Views: 727
Reputation: 96572
You can use a case statement in a where clause, but it can generate performance issues, so you may want to try a different approach if you have a large dataset. A correlated subquery would not be a good alternative approach; a derived table or CTE might be.
Upvotes: 4