SELECT concat( date_format( time, '%Y-%m-%d %H:' ) , floor( date_format( time, '%i' ) /10 ) ) AS c, count(1)
FROM table
WHERE time between "2019-07-08 00:00:00" and "2019-07-09 00:00:00"
GROUP BY c
order by c
意思为:每十分钟计算一次count值
本文介绍了一种使用SQL进行数据查询的方法,具体为每隔十分钟计算一次指定时间范围内的count值。通过这种方式可以有效地对数据进行周期性的统计分析。
SELECT concat( date_format( time, '%Y-%m-%d %H:' ) , floor( date_format( time, '%i' ) /10 ) ) AS c, count(1)
FROM table
WHERE time between "2019-07-08 00:00:00" and "2019-07-09 00:00:00"
GROUP BY c
order by c
意思为:每十分钟计算一次count值
891
1万+

被折叠的 条评论
为什么被折叠?