What kind of problem are you having? You can use the ordinal postion. ORDER BY 2 [ASC|DESC]. 2 represents the second column.
-----Original Message----- From: Julien Martin To: '[EMAIL PROTECTED]' Sent: 5/5/04 12:41 PM Subject: AVG function in order by clause Hello, Thanks a lot for the replies. I have changed the 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 GROUP BY ES.DB_ESTABLISHMENT_ID HAVING AVG(DB_GRADE) > 2 ORDER BY AVG(GRADE) ************************** Now I am having a problem with the order by clause. How can I have the AVG function in the ORDER BY clause or how can I sort by average grade? Thanks in advance, Julien Martin. -- 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]