mysql按日、月、周、季度分组_MySQL
程序员文章站
2024-02-04 22:34:34
...
按日分组:select DATE_FORMAT(o.OrderDate,'%Y%m%d') weeks,count(*) count from orders o group by weeks;
按月分组:select DATE_FORMAT(o.OrderDate,'%Y%m') weeks,count(*) count from orders o group by weeks;
按周分组: select DATE_FORMAT(o.OrderDate,'%Y_%u') weeks,count(*) count from orders o group by weeks;
按季度分组:select CONCAT(YEAR(o.OrderDate),'_',quarter(o.OrderDate)) qu,count(*) count from orders o group by qu;
按月分组:select DATE_FORMAT(o.OrderDate,'%Y%m') weeks,count(*) count from orders o group by weeks;
按周分组: select DATE_FORMAT(o.OrderDate,'%Y_%u') weeks,count(*) count from orders o group by weeks;
按季度分组:select CONCAT(YEAR(o.OrderDate),'_',quarter(o.OrderDate)) qu,count(*) count from orders o group by qu;
上一篇: 阿里云携领先SDN能力,亮相全球网络技术盛会ONS 大数据
下一篇: phpcms一键排字完美插件