Your where clause is confusion. Are you wanting to retrieve rows where the
DB_Grade is greater than 2? AVG(DB_GRADE) is not a valid restriction. Are
you wanting HAVING AVG(DB_GRADE) > 2 ?
-----Original Message-----
From: Julien Martin
To: '[EMAIL PROTECTED]'
Sent: 5/5/04 12:12 PM
Subject: Use of AVG in where clause
Hello,
I have a sql query as follows:
**************************
SELECT
DB_ESTABLISHMENT_NAME,
AVG(DB_GRADE)
FROM
ESTABLISHMENTS ES LEFT OUTER JOIN GRADES GR ON
ES.DB_ESTABLISHMENT_ID=GR.DB_ESTABLISHMENT_ID
WHERE
AVG(DB_GRADE) > 2
GROUP BY
ES.DB_ESTABLISHMENT_ID
;
**************************
and I get the following error:
ERROR 1111: Invalid use of group function
Can anyone tell me how to use a function in the where clause?
Thanks in advance,
Julien.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]