按月分组: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 LAST_DAY(o.OrderDate) FROM orders o