MySQL/문제풀이
[HackerRank] INNER JOIN : Average Population of Each Continent
MINNI_
2021. 3. 15. 04:03
1. 문제
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:
2. 답
SELECT country.continent, FLOOR(AVG(city.population))
FROM city
INNER JOIN country ON city.countrycode = country.code
GROUP BY country.continent
3. KEY POINT
- INNER JOIN : 양쪽 테이블의 모두 있는 정보를 합침
- AVG(컬럼이름) : 해당 컬럼의 평균
- FLOOR() : 내림
- GROUP BY : 기준을 중심으로 그룹화
hackerrank.com/challenges/average-population-of-each-continent/problem?h_r=internal-search
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