要求:按事件发生日期(eventTime)统计每天的事件数量,即每天就多少事件发生。
select eventTime,totalEvent from
(select date(eventTime) as eventTime,count(*) as totalEvent
from 表名
group by date(eventTime)
) as tempTable
数据库中事件发生时间是yyyy-MM-dd HH:mm:ss格式,date函数是提取eventTime中日期部分
本文介绍了一种统计数据库中每日事件数量的方法,通过SQL查询,使用date函数从事件时间戳中提取日期,按天分组并计数。
要求:按事件发生日期(eventTime)统计每天的事件数量,即每天就多少事件发生。
select eventTime,totalEvent from
(select date(eventTime) as eventTime,count(*) as totalEvent
from 表名
group by date(eventTime)
) as tempTable
数据库中事件发生时间是yyyy-MM-dd HH:mm:ss格式,date函数是提取eventTime中日期部分
1471
2564
1682
1万+

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