You can use the case statement in the where clause, but it can cause performance problems, so you can try a different approach if you have a large dataset. A correlated subquery would not be a good alternative approach; view or CTE may be.
Hlgem source
share