解释:

DATE_FORMAT() 函数用于以不同的格式显示日期/时间数据。

1、表字段格式:

mysql 时间 按季度分组 mysql按年份分组_字段

按天分组很好做直接 GROUP BY date

##按日期分组
SELECT sum(public)  public FROM tax  GROUP BY date; 

##按月分组 as 别名不能跟原始字段名重复
SELECT DATE_FORMAT(date,'%Y-%m') as time,sum(public)  public FROM tax  GROUP BY time; 

##按年分组
SELECT DATE_FORMAT(date,'%Y') as time,sum(public)  public FROM tax  GROUP BY time;

mysql 时间 按季度分组 mysql按年份分组_mysql sql日期_02