At 11:24 -0500 9/3/03, Cory Hicks wrote:
Hey folks,

I am trying to run the following sql query in mysql:

SELECT TD.project_id, P.project_manager
FROM time_daily TD
INNER JOIN projects P ON P.project_id = TD.time_project_id
WHERE TD.time_user_id = 'xpt' AND (
SUM( TD.time_hours_worked ) <> '0.00'
)

And I keep getting the #1111 errno.....- Invalid use of group function -

I don't want to pull out any rows where the SUM of time_hours_worked is
'0.00'...

I would be most grateful if anyone has any suggestions....

You cannot use aggregate functions like SUM() in the WHERE clause. That's self-contradictory, because WHERE determines which rows to select, whereas SUM() can be computed only after the rows have been selected. :-)

You might want to select the SUM() values into a temporary table,
then use that in a join with your original table.


Many thanks!


Cory
--
Cory Hicks <[EMAIL PROTECTED]>
TRI International


--
Paul DuBois, Senior Technical Writer
Madison, Wisconsin, USA
MySQL AB, www.mysql.com

Are you MySQL certified? http://www.mysql.com/certification/


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to