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();//返回年份