I have a code snippet where I have a bunch of 'where' conditions merged with 'and' clause. I want to do the below operation:
...
and admission_date > release_date
and case when @sample = 'typeA'
then
(
(isnull(@toll_id, 0) > 0 and exists(select fk_id from dbo.tollitem where toll_id = @toll_id and isdel=0))
or
(isnull(@toll_id, 0) = 0)
)
So I have a parameter as @Sample which has two values - Type A or Type B. I want to check the condition on where clause only when @sample = typeA. Above is my code and I am getting incorrect syntax error. Any help?