Thanks for the thought. The HAVING clause, while it does belong behind the group by clause doesn't seem to be the source of the problem - I get the same error even when I take the HAVING clause out.
Thanks, Eric ----- Original Message ----- From: "Lopez David E-r9374c" <[EMAIL PROTECTED]> To: "'Eric Ellsworth'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, January 27, 2004 10:09 AM Subject: RE: Syntax Check: Group BY with Joins > Eric > > Try putting the "HAVING" clause after group by. I believe > "having" is the last clause (may be LIMIT). > > David > > > -----Original Message----- > > From: Eric Ellsworth [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, January 27, 2004 8:01 AM > > To: [EMAIL PROTECTED] > > Subject: Syntax Check: Group BY with Joins > > > > > > Hi, > > I'm having trouble with this query: > > > > SELECT Max(DATE_ADD('1970-1-1',INTERVAL Lastupdate/3600/24 > > DAY)) as BaskDate, ofm_baskets.Code, > > Sum(ofm_baskets.Quantity) AS TotalQty > > FROM (ofm_basklist INNER JOIN ofm_basklupd ON > > ofm_basklist.Session_id = ofm_basklupd.Session_id) INNER JOIN > > ofm_baskets ON ofm_basklist.Basket_id = ofm_baskets.Id > > GROUP BY ofm_baskets.Code > > HAVING (((ofm_basklist.Order_id)=0)) > > ORDER BY Max(DATE_ADD('1970-1-1',INTERVAL Lastupdate/3600/24 DAY)); > > > > I get the following error: > > ERROR 1111: Invalid use of group function > > > > Can someone give me an idea of what's wrong with this query? > > I'm using MySQLd version 4.0.16. > > > > Thanks, > > > > Eric > > > > > > > > -- > 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]