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
|
1783 Discussions
|
Please Login in order to post a comment
SELECT CO.Continent, FLOOR(AVG(C.Population)) FROM Country CO JOIN City C ON C.CountryCode = CO.Code GROUP BY CO.Continent;
This problem statement has some issues. Admin should look into it. Also some continenet can have 0 populations considering if city table doesn't have any data for a continent.
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