There's a table which is called cities
and looks like so:
id | city | population | year
I simply need:
For each city select maximal amount of population and year of that maximal population. A solution without nested queries is preferred
So I tried this:
SELECT `city`, MAX(`year`), MAX(`population`) FROM `cities` GROUP BY `city`
But it gives wrong results. What am I doing wrong?
MAX(year)
you just needSELECT city, year, MAX(population) FROM cities GROUP BY city