Search

Average Population of Each Continent

생성일
2022/03/18 16:52
플랫폼
해커랭크
태그
JOIN
level
분류

Problem

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:

Code

 #1

Idea

구해야 하는 것 : continents 의 이름(country.continent) 과 그 continents 에 속한 city 의 populations(city.population) 의 평균의 내림값

 Code

select country.continent, floor(avg(city.population)) from city join country on city.countrycode = country.code group by country.continent
SQL
복사

Solution

Commentary

avg 와 floor 몰랐다.