mysql时间字符串按年/月/天/时分组查询 -- date_format
作者:互联网
SELECT DATE_FORMAT( deteline, "%Y-%m-%d %H" ) , COUNT( * )
FROM test
GROUP BY DATE_FORMAT( deteline, "%Y-%m-%d %H" )
查询某天:
deteline, "%Y-%m-%d"
某时:
deteline, "%Y-%m-%d %H"
依次类推。
其实就是对dateline进行处理,然后再对处理后的数据分组
eg:统计每小时创建的个数
SELECT DATE_FORMAT( create_time, "%Y-%m-%d %H" ) as time , COUNT( * ) as count FROM pdca GROUP BY DATE_FORMAT( create_time, "%Y-%m-%d %H" )
标签:-%,GROUP,FORMAT,--,format,按年,time,DATE,deteline 来源: https://www.cnblogs.com/yuminhu/p/15740326.html