MySQL Forums
Forum List  »  General

Sum not working correctly
Posted by: Granville Phillips
Date: January 30, 2015 09:21AM

Seems like a simple query. The sum(d.`TargetTime`) is summing more rows than it should.

Here is the entire query. I believe it has something to do with the second sum Sum(t.dbHours) from a left join. Just not sure what to do about it.

Any help is greatly appreciated.

SELECT sum(d.`TargetTime`) as SumofTT, Sum(t.dbHours) as SumofHours, l.WebAssigned
FROM `dispatch report` d
LEFT JOIN dispatch_local l
ON d.`RepairOrderNo` = l.RepairOrder
AND d.`RepairOrderLineItem` = L.RepairLine
LEFT JOIN tbtimecard t
ON t.dbSAPRO = d.`RepairOrderNo`
AND t.dbSAPROLine = d.`RepairOrderLineItem`
WHERE (d.`RepairType` = 'ZRPO' OR d.`RepairType` = 'IHRWK') and d.`LegacyWorkCell` <> 'OUTSOURC' and d.`TargetTime` IS NOT NULL
GROUP BY l.WebAssigned

Options: ReplyQuote


Subject
Written By
Posted
Sum not working correctly
January 30, 2015 09:21AM
January 30, 2015 10:18AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.