Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to Void Orders using SQL

Status
Not open for further replies.

MsHart2u

Programmer
Jul 16, 2003
30
US
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 order #'s in this results set.
SQL:
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.
Kathy
GP Novice


[blue]Kathy,
Bus Sys Analyst[/blue]
"I am always doing that which I can not do, in order that I may learn how to do it."– Pablo Picasso
The person who says it can't be done shouldn't interrupt the person who is doing it.—Chinese Proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top