Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2010

    Unanswered: group function error

    i got error

    [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM xydata a
    INNER JOIN fm4features f ON = a.' at line 5

    SELECT gpstime, 
           MIN(gpstime) `mn`, 
           MAX(gpstime) `mx`, 
    SEC_TO_TIME(SUM(TIME_TO_SEC(TIMEDIFF(max(gpstime), min(gpstime))))) AS  totalworktime
                             FROM   xydata a 
                             INNER JOIN fm4features f ON =
                             WHERE  objectid = 17 
                                    AND clientid = 1
                                    AND gpstime > '2010-05-11 00:00:00' 
                                    AND gpstime < '2010-05-11 23:59:59' 
                                    AND f.dataid = 1
                                    AND f.VALUE = '1' 
                                    AND gpstime IS NOT NULL                               
    GROUP  BY Date_format(gpstime, '&#37;Y-%m-%d') 
    ORDER  BY gpstime ASC
    how to solve this error please help me
    Last edited by baktha.thalapathy; 05-12-10 at 02:23. Reason: ee

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    you have nested aggregate functions, which is not allowed

    i.e. you have MAX and MIN and then you're trying to SUM them

    what are you trying to achieve with that query? | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts