I have a Stored Procedure called spGetOrders which accepts a few parameters: @startdate and @enddate. This queries an \"Orders\" table. One of the columns in the table is
Or this:
select * from orders o
where o.orderdate between @startdate AND @enddate
and ( (@Closed = 1 AND o.ClosedDate IS NULL)
OR (ISNULL(@Closed, 0) <> 1 AND o.ClosedDate IS NOT NULL)
)
It looks like you want all the orders between two dates that have inconsistent Close information. The other suggestions are probably as good (or better) but I'm pretty sure that this works and is readable to me (most of the other suggestions appeared as I was typing).
Good luck!