Hi I am trying to do the qry below and I keep getting “Cannot have aggregate function in expression” error on the subqry sum line. Any way to make this work?
SELECT ID,
DateColumn,
Contamination,
BrokenGlass,
OtherReasons,
SUM(Contamination) + SUM(BrokenGlass) + SUM(OtherReasons) AS Total,
SUM(Contamination) / Total AS Expr1,
(SELECT SUM(Contamination)/ SUM(SUM(Contamination) + SUM(BrokenGlass) + SUM(OtherReasons))
FROM tbltest T2
WHERE T2.ID <= T2.ID) AS RunningSum
FROM tbltest
GROUP BY ID, DateColumn, Contamination, BrokenGlass, OtherReasons
Edited
The results being incorrect is a whole different problem than what was originally asked and I’m going to have to take a stab in the dark at this because I know nothing about your project, but here you go and maybe it can get you started in the right direction.