혜온의 이것저것

[HackerRank] Average Population of Each Continent (MySQL) 본문

Data Analysis/SQL

[HackerRank] Average Population of Each Continent (MySQL)

혜온 :) 2022. 8. 29. 15:19

https://www.hackerrank.com/challenges/average-population-of-each-continent/problem?isFullScreen=true 

 

Average Population of Each Continent | HackerRank

Query the names of all continents and their respective city populations, rounded down to the nearest integer.

www.hackerrank.com

 

문제

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: 

 

풀이
select c2.continent, floor(avg(c1.population))
from city c1, country c2
where c1.countrycode = c2.code
group by c2.continent
Comments