HackerRank Average Population of Each Continent problem solution

In this HackerRank Average Population of Each Continent problem solution Given the CITY and COUNTRY tables, query the names of all the continents (COUNTRY.Continent) and their respective average city populations (CITY.Population) rounded down to the nearest integer.

Note: CITY.CountryCode and COUNTRY.Code are matching key columns.

Input Format

The CITY and COUNTRY tables are described as follows: 

HackerRank Average Population of Each Continent problem solution

HackerRank Average Population of Each Continent problem solution


Problem solution Oracle.

select co.continent, trunc(avg(ci.population)) from city ci inner join country co on ci.countrycode = co.code group by co.continent;

Problem solution in Oracle.

select Country.Continent , floor(avg(City.Population)) from City , Country
where City.CountryCode = Country.Code
group by Country.Continent;


Post a Comment

0 Comments