If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > group function error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-12-10, 02:22
baktha.thalapathy baktha.thalapathy is offline
Registered User
 
Join Date: Apr 2010
Posts: 4
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 f.id = a.' at line 5


Code:
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 f.id = a.id
                         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
Reply With Quote
  #2 (permalink)  
Old 05-12-10, 06:07
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
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?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On