I ran the following query to determine open orders that should be voided. After reviewing and approving them, we need to know how we can void these orders using SQL. We have over 30K SOPNUMBE order #'s over the years in this results set.
SELECT distinct ca.custname, ca.CUSTNMBR, datediff(day,getdate(),oh.ReqShipDate) Age,
oh.ReqShipDate,oh.SOPNUMBE,
ca.HOLD AcctHold,
oh.SUBTOTAL
from RM00101 ca join SOP10100 oh on ca.CUSTNMBR = oh.CUSTNMBR
where ca.INACTIVE =0 AND oh.SOPTYPE=2 and oh.voidstts = 0
and oh.reqshipdate<(getdate()-90)
and not exists
(--order is not yet in the history table
select distinct b.* from sop10200 b where b.sopnumbe = oh.sopnumbe and b.soptype = 2 and b.qtyfulfi > 0
)
Thank you in advance.
Data Analyst
GP Novice