以 15 分钟为间隔对 mysql 查询进行分组
我有一个监控系统,它每 n 秒收集一次数据(n 大约为 10,但会有所不同).我想按 15 分钟的时间间隔汇总收集的数据.有没有办法将时间戳值合并为 15 分钟的块以允许分组工作?
I've got a monitoring system that is collecting data every n seconds (n is approximately 10 but varies). I'd like to aggregate the collected data by 15 minute intervals. Is there a way to consolidate the timestamp values into 15 minute chunks to allow for grouping to work?
推荐答案
SELECT FLOOR(UNIX_TIMESTAMP(timestamp)/(15 * 60)) AS timekey
FROM table
GROUP BY timekey;
相关文章