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
|
1781 Discussions
|
Please Login in order to post a comment
Not sure why, when the question asks to round off to the nearest integer, it doesn't accept the solution when ROUND() is used. Needed to do FLOOR(). Question needs to be changed?
SELECT co.continent , floor(avg(ci.population)) FROM city ci INNER JOIN country co ON ci.COUNTRYCODE = co.CODE GROUP BY co.CONTINENT;
to those this query is not working with floor() function please check which join you are using if you are using left join it'll not work... Here Inner join will be used because you want population avg for continents and it should match in both tables-[ continents in country table must have population of cities in city table, if no population it'll be NULL]... Hope it will help
select co.continent, floor(avg(c.population)) from city c join country co on c.countrycode = co.code group by co.continent
SELECT CO.Continent, AVG(CI.Population) FROM CITY CI INNER JOIN COUNTRY CO ON CI.CountryCode = CO.Code GROUP BY CO.Continent;