only_full_group_by报错

如题所述

第1个回答  2022-07-28
报错了:

### Cause: java.sql.SQLSyntaxErrorException: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'xxxxxxx'; this is incompatible with sql_mode=only_full_group_by

; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'xxxxxx'; this is incompatible with sql_mode=only_full_group_by

原因是:在调用count(*)聚合方法时, 增加了排序字段,而shardingsphere默认会分表查询前,将聚合排序字段,拼接到count后:

所以去掉排序就好了。
相似回答