Average Population of Each Continent

Sort by

recency

|

1723 Discussions

|

  • + 1 comment

    What is the necessity of using group by?

  • + 2 comments
    SELECT
        COUNTRY.Continent,
        FLOOR(AVG(CITY.Population))
    FROM
        CITY
    INNER JOIN
        COUNTRY
    ON
        CITY.CountryCode = COUNTRY.Code
    GROUP BY
        COUNTRY.Continent;
    
  • + 0 comments

    SELECT CO.Continent, TRUNCATE(AVG(CI.POPULATION),0) FROM CITY AS CI INNER JOIN COUNTRY AS CO ON CI.CountryCode = CO.Code GROUP BY CO.Continent;

  • + 0 comments

    Gah daymmn, why should we use floor?

    SELECT COUNTRY.CONTINENT, ROUND(AVG(CITY.POPULATION), 2)
    FROM CITY
    LEFT JOIN COUNTRY ON CITY.COUNTRYCODE = COUNTRY.CODE
    GROUP BY COUNTRY.CONTINENT 
    

    Thought this is already correct

  • + 0 comments

    select ctr.continent, floor(avg(c.population)) as average_population from city c join country ctr on ctr.code = c.countrycode group by ctr.continent;