Average Population of Each Continent

  • + 2 comments

    There's some ambuiguity in the table data..... A given country's population should match the sum of population of all the cities in that country......

    Hence this query should also pass the test cases:

    SELECT con,FLOOR(pop/cnt) from (SELECT Country.Continent as con,COUNT(*) as cnt,SUM(Country.Population) as pop from CITY JOIN COUNTRY ON City.CountryCode=Country.Code GROUP BY Country.Continent) tab1;

    But only this does:

    SELECT con,FLOOR(pop/cnt) from (SELECT Country.Continent as con,COUNT(*) as cnt,SUM(CITY.Population) as pop from CITY JOIN COUNTRY ON City.CountryCode=Country.Code GROUP BY Country.Continent) tab1;

    Or Am I wrong somewhere....pls point it out if thats the case....