我正在尝试运行这个SQL查询:
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
但是我看到了这个错误:
#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
我无法确定查询中的错误位置
as response_seconds
之前把)
关闭得太早了。它应该在(select...)
内部,但你却把它放在外面了。correct syntax to use near FROM
意味着你必须在那之前立即查找问题所在。 - Michael BerkowskiFROM
- 一个来自嵌套查询,另一个来自 tickets,你需要将tickets
加入到查询中。 - Alon Eitan(
,应该在GROUP BY
之后最终关闭,但第6个闭合的)
出现在as response_seconds
之前。 - Michael Berkowski