下列範例可達到要求。
update HBSpecM set PURWgt=PUR.QtyCH from HBSpecM HBM left join (select D.BookNum,HBM.ProdNo,QtyCH=SUM(QtyCH) from PUR510D D left join HBMatAnti HBM on D.CorpNo=HBM.CorpNo and D.ProdNo=HBM.AntiProdNo where D.CorpNo='20001' group by D.BookNum,HBM.ProdNo) PUR on HBM.BookNum=PUR.BookNum and HBM.ProdNo=PUR.ProdNo where HBM.CorpNo='20001'
沒有留言:
張貼留言