Trying to establish a production percentage based on a couple of values from the same table with the following statement:
SELECT avg(sum([Actual]/
(sum(NULLIF([Team Members],0)/(sum(NULLIF([Actual Min],0)))))))
FROM [Shift Production Log]
WHERE [Date] >= DATEADD(dw, -2, :dvalue) AND
[Line] = :Lpram
And I'm getting the following error:
Cannot perform an aggregate function on an expression containing an aggregate or a subquery.
I should also specify I am doing this through a SCADA system that will place parameters that I bind, thus the "Lpram" and "dvalue". Those work in other statements fine, so it appears my problem is the actual select statement itself. Thank you!
Sample Data: