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" )