I have several queries in an MS Access database that I am rewriting in a SQL stored procedure. The queries have several filters applied to the same field.
select *
from DT.SM_T_OCDetails
where
(Rest1 <> 'S' Or Rest1 Is Null)
and (Rest2 <> 'S' Or Rest2 Is Null)
and (Rest3 <> 'S' Or Rest3 Is Null)
and (Rest4 <> 'S' Or Rest4 Is Null)
Is there a better way to write the
(Rest1 <> 'S' Or Rest1 Is Null)
part of the queries? I looked at coalesce for it but unless I am doing it wrong, I don’t think that works.
Thanks
Using coalesce:
Though I actually think your original is clearer.