当我加入一个额外的表时,我的SUM值会更改。
SELECT
woo.SI_NUMBER, woo.woo_auto_key,sum(wtl.HOURS) AS "Labor Hours"
FROM
WO_OPERATION woo
LEFT JOIN WO_QUOTE_HEADER wq ON wq.WOO_MASTER = woo.WOO_AUTO_KEY
LEFT JOIN SYS_USERS sysur ON woo.SYSUR_MANAGER = sysur.SYSUR_AUTO_KEY
LEFT JOIN WO_TASK wot ON woo.WOO_AUTO_KEY = wot.WOO_AUTO_KEY
LEFT JOIN WO_TASK_LABOR wtl ON wot.WOT_AUTO_KEY = wtl.WOT_AUTO_KEY
--LEFT JOIN WO_TASK_SKILLS wts ON wot.WOT_AUTO_KEY = wts.WOT_AUTO_KEY
WHERE
woo.SI_NUMBER LIKE 'M%'
GROUP BY woo.SI_NUMBER,woo.WOO_AUTO_KEY
当我加入WO_TASK_SKILLS表时,我的SUM值更改为不正确。我只想知道每个工单有几个小时。小时数在“ wo_task_labor”表上,该表通过wo_taks表连接到主工作订单表(wo_operation)。
我也想加入wo_task_skills表的原因是因为我也想求和估计的小时数(该值没有相同的名称)