select .. FROM
where (Table.Type = 'imp' and Table.ArrDate >=@DateStart and Table.ArrDate < @DateEnd) OR (Table.Type = 'exp' and Table.DepDate >=@DateStart and Table.DepDate < @DateEnd)
Alternative solution
Code:
select * from
(select .., case when Type = 'imp' then ArrDate
when Type = 'exp' then DepDate end) as DepArr FROM .. )
Derived where Derived.DepArr >=@DateStart and DepArr <@DateEnd
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.