Average Population of Each Continent

  • + 1 comment

    SELECT p.continent, FLOOR(COALESCE(AVG(NULLIF(c.population, 0)), 0)) AS avg_city_population FROM Country AS p LEFT JOIN City AS c ON p.code = c.countrycode GROUP BY p.continent;

    why this is wrong