which is not functionally dependent on columns in group by clause this is incompatible with sql_modeonly_full_group

2k Views Asked by At
select countrycode,name, max(population) 
from city 
group by CountryCode LIMIT 0, 1000  

Error Code: 1055. Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'world.city.Name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by 0.000 sec

Help me out with this problem.

1

There are 1 best solutions below

8
nbk On BEST ANSWER

As the error message says you need for all columns in the select a aggregation function or they have to be in the GROUP BY

in your case put it also in the GROUP BY

select countrycode,name, max(population) 
from city 
group by CountryCode,name LIMIT 0, 1000