SELECT
timestamp,
name,
count(b.name)
FROM time a, id
WHERE …
GROUP BY
UNIX_TIMESTAMP(timestamp) DIV 300, name
我上面有桌子
并希望计算created_at
列
分组为created_at
的5分钟间隔,
比如计数create_at
列
从2016-09-01 16:21:29
到2016-09-01 16:26:29
答案 0 :(得分:0)
你必须使用FLOOR()函数来获取每五分钟一次的唯一整数
SELECT timestamp, name, count(b.name) FROM time a, id WHERE … GROUP BY FLOOR(UNIX_TIMESTAMP(timestamp)/300)