3 group by和order by连用时,order by必须放在聚合函数中,聚合函数任意,不放的话报错:
Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'daily.t_daily.update_time' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
2 springboot中
@Query("select function('date_format',d.updateTime,'%Y') as year from t_daily d group by year order by MIN(d.updateTime) desc ")//按照年份
List<String>findGroupYear();//返回年份