mysql按照小时统计数量

文章描述:

假如我们要把数据按每小时进行统计,种情况可以通过from_unxitime()函数和group by结合,sql语句如下:

 

select from_unixtime(newstime,'%Y-%m-%d %H:00:00') as time,count(*) as total from sys_phone_code 
WHERE FROM_UNIXTIME(newstime,'%Y-%m-%d') = '2022-12-30'
group by from_unixtime(newstime,'%Y-%m-%d %H:00:00')

发布时间:2023/01/10

发表评论