【发布时间】:2016-04-27 01:55:41
【问题描述】:
收到以下错误:
Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'world.country.Code' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
运行以下查询时:
select countrylanguage.language, country.code, sum(country.population*countrylanguage.percentage/100)
from countrylanguage
join country on countrylanguage.countrycode = country.code
group by countrylanguage.language
order by sum(country.population*countrylanguage.percentage) desc ;
使用 MySQL 世界测试数据库 (http://dev.mysql.com/doc/index-other.html)。不知道为什么会这样。当前运行 MYSQL 5.7.10。
有什么想法吗??? :O
【问题讨论】:
-
您启用了
ONLY_FULL_GROUP_BY选项,这消除了MySQL 对GROUP BY的宽松规则。 -
MySQL 5.7 中该选项的默认值已更改。
-
@Barmar 从什么变成什么?
-
@OlleHärstedt 从关闭到打开。
标签: mysql sql aggregate mysql-error-1055