LloydDobler
Technical User
Hi everyone, having a little trouble with what I thought would be a simple calculation. I need to group the following by MachineNumber. What I need to do is add the totalScrap & totalPRD, and divide totalScrap into the totalPRD for each machine to give us PPM. Below is my statement, some values returned are correct, but others are off by quite a bit and I don't understand why. Hope someone can help.
SELECT
machinenumber, sum((ScrQnty1 + ScrQnty2 + ScrQnty3 + ScrQnty4) /(QuantityProduced + ScrQnty1 + ScrQnty2 + ScrQnty3 + ScrQnty4)*1000000) as PPM
FROM tbl_Production
WHERE
((QuantityProduced + ScrQnty1 + ScrQnty2 + ScrQnty3 + ScrQnty4) > 0) AND (PRDdate BETWEEN '01/01/04' AND '01/31/04')
GROUP BY MachineNumber
ORDER BY MachineNumber
SELECT
machinenumber, sum((ScrQnty1 + ScrQnty2 + ScrQnty3 + ScrQnty4) /(QuantityProduced + ScrQnty1 + ScrQnty2 + ScrQnty3 + ScrQnty4)*1000000) as PPM
FROM tbl_Production
WHERE
((QuantityProduced + ScrQnty1 + ScrQnty2 + ScrQnty3 + ScrQnty4) > 0) AND (PRDdate BETWEEN '01/01/04' AND '01/31/04')
GROUP BY MachineNumber
ORDER BY MachineNumber