当前位置: 移动技术网 > IT编程>数据库>Mysql > mysql 获取规定时间段内的统计数据

mysql 获取规定时间段内的统计数据

2017年12月12日  | 移动技术网IT编程  | 我要评论
mysql 获取规定时间段内的统计数据 按年统计 select count(*), date_format(order_info.creat

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 

具体变换可以自己根据需求变更

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网