mysql语句中使用group by会遇到如下报错信息:
Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column '数据库名.表名.字段名' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
mysql 5.7版本默认的sql配置是:sql_mode="ONLY_FULL_GROUP_BY",这个配置严格执行了"SQL92标准"。
这里推荐mysql的函数
ANY_VALUE() ,使用该函数不需要修改mysql配置文件等就可以解决上诉错误
参考文章:
https://blog.youkuaiyun.com/u014079773/article/details/93722761