mysql 猎取划定时间段内的统计数据
按年统计
SELECT count(*), DATE_FORMAT(order_info.create_time, '%Y-%m-%d') AS count_by_date FROM order_info WHERE DATE_FORMAT(order_info.create_time, '%Y') = '2017' GROUP BY count_by_date ORDER BY NULL
按月统计
SELECT count(*), DATE_FORMAT(order_info.create_time, '%Y-%m-%d') AS count_by_date FROM order_info WHERE DATE_FORMAT(order_info.create_time, '%Y-%m') = '2017-04' GROUP BY count_by_date ORDER BY NULL
细致变动能够本身依据需求变动。
相干引荐:
统计数据库天天的数据增长量
SQL语句技能:按月统计数据
Oracle 优化统计数据之直方图(histograms)
以上就是mysql猎取划定时间段内统计数据的要领教程的细致内容,更多请关注ki4网别的相干文章!