Wednesday, August 6, 2008

orders due

Declare
@days as int
set @days = 5
select a.sopnumbe, a.docdate, a.ReqShipdate, datediff(day, getdate(), a.ReqShipdate) as days_left
from sop10100 a
where a.soptype = 2 and a.voidstts = 0
and datediff(day, getdate(), a.ReqShipdate) >= (0 - @days) and datediff(day, getdate(), a.ReqShipdate) <= @days
and not exists
(
select b.* from sop10200 b where b.sopnumbe = a.sopnumbe and b.soptype = 2 and b.qtyfulfi > 0
)

No comments: