I need to order the following by sumofrate.
[code=sql]SELECT [name], sum([pieces]) AS sumofpieces, sum([hours]) AS sumofhours, sum([pieces])/sum([hours]) AS sumofrate, sum([errors]) AS sumoferrors, [department]
FROM tblTempRate
WHERE name in (SELECT name
FROM tblTempRate
GROUP BY name, department
HAVING sum(hours)>4)
GROUP BY [name], [department][/code]
Whenever I add "ORDER BY sum([pieces])/sum([hours])" to the end of the statement I get an "overflow" error. I've tried to change my sumofrate in the SELECT and ORDER BY clauses to "sum(nz([pieces],0))/sum(nz([hours],0))" in case this was some type of NULL error, but no go. Both pieces and hours are of type double, the only thing I can think of is too many decimal places in some of the results. Any ideas?
Help would be much appreciated. Thanks!!
[code=sql]SELECT [name], sum([pieces]) AS sumofpieces, sum([hours]) AS sumofhours, sum([pieces])/sum([hours]) AS sumofrate, sum([errors]) AS sumoferrors, [department]
FROM tblTempRate
WHERE name in (SELECT name
FROM tblTempRate
GROUP BY name, department
HAVING sum(hours)>4)
GROUP BY [name], [department][/code]
Whenever I add "ORDER BY sum([pieces])/sum([hours])" to the end of the statement I get an "overflow" error. I've tried to change my sumofrate in the SELECT and ORDER BY clauses to "sum(nz([pieces],0))/sum(nz([hours],0))" in case this was some type of NULL error, but no go. Both pieces and hours are of type double, the only thing I can think of is too many decimal places in some of the results. Any ideas?
Help would be much appreciated. Thanks!!
Comment