i am trying to run this SQL Query:
SELECT avg(response_seconds) as s FROM
( select time_to_sec( timediff( from_unixtime( floor( UNIX_TIMESTAMP(u.datetime)/60 )*60 ), u.datetime) ) ) as response_seconds
FROM tickets t JOIN ticket_updates u ON t.ticketnumber = u.ticketnumber
WHERE u.type = 'update' and t.customer = 'Y' and DATE(u.datetime) = '2016-04-18'
GROUP BY t.ticketnumber)
AS r
but i am seeing this error:
#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 tickets t JOIN ticket_updates u ON t.ticketnumber = u.ticketnumber WHE' at line 3
and i cannot work out where the error is in the query
)too early beforeas response_seconds. That belongs inside the(select...)but you have it outside. Thecorrect syntax to use near FROMmeans you must look immediately before that to find the issue.FROMs - One from the nested query and the second from tickets, you need toJOIN ticketsto the query(, which should be finally closed afterGROUP BY, but the 6th closing)occurs just beforeas response_secondsinstead.