We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Average Population of Each Continent
Average Population of Each Continent
Sort by
recency
|
1769 Discussions
|
Please Login in order to post a comment
Given the CITY and COUNTRY tables, query the names of all the continents (COUNTRY.Continent) and their respective average city populations (CITY.Population) rounded down to the nearest integer.
SELECT CN.CONTINENT,FLOOR(AVG(C.POPULATION)) FROM CITY C INNER JOIN COUNTRY CN ON C.COUNTRYCODE=CN.CODE GROUP BY CN.CONTINENT;
SELECT CONTINENT, ROUND(AVG(CITY.POPULATION),0) FROM COUNTRY JOIN CITY ON COUNTRYCODE = CODE GROUP BY CONTINENT;==================================Africa 274439 Asia 693038 Europe 175138 Oceania 109189 South America 147435=============
SELECT country.continent, FLOOR(AVG(city.population)) FROM city JOIN country ON city.countrycode = country.code GROUP BY country.Continent;
This query shows me wrong answer if I use ROUND instead of FLOOR. Can anyone tell me the reason?