当我加入 3 个表时,我不断得到错误的总和值。这是表的ERD的图片:
(原文:http: //dl.dropbox.com/u/18794525/AUG%207%20DUMP%20STAN.png)
这是查询:
select SUM(gpCutBody.actualQty) as cutQty , SUM(gpSewBody.quantity) as sewQty
from jobOrder
inner join gpCutHead on gpCutHead.joNum = jobOrder.joNum
inner join gpSewHead on gpSewHead.joNum = jobOrder.joNum
inner join gpCutBody on gpCutBody.gpCutID = gpCutHead.gpCutID
inner join gpSewBody on gpSewBody.gpSewID = gpSewHead.gpSewID