mysql - SELECT list is not in GROUP BY clause and contains nonaggregated column -


this question has answer here:

receiving following error:

expression #2 of select list not in group clause , contains nonaggregated column 'world.country.code' not functionally dependent on columns in group clause; incompatible sql_mode=only_full_group_by 

when running following query:

select countrylanguage.language, country.code, sum(country.population*countrylanguage.percentage/100) countrylanguage join country on countrylanguage.countrycode = country.code group countrylanguage.language order sum(country.population*countrylanguage.percentage) desc ; 

using mysql world test database (http://dev.mysql.com/doc/index-other.html). no idea why happening. running mysql 5.7.10.

any ideas??? :o

as @brian riley said should either remove 1 column in select

select countrylanguage.language ,sum(country.population*countrylanguage.percentage/100) countrylanguage join country on countrylanguage.countrycode = country.code group countrylanguage.language order sum(country.population*countrylanguage.percentage) desc ; 

or add grouping

select countrylanguage.language, country.code, sum(country.population*countrylanguage.percentage/100) countrylanguage join country on countrylanguage.countrycode = country.code group countrylanguage.language, country.code order sum(country.population*countrylanguage.percentage) desc ; 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -