SQL

[해커랭크] Average Population of Each Continent

주스 JUICE 2023. 7. 17. 18:38
728x90

https://www.hackerrank.com/challenges/average-population-of-each-continent/problem?isFullScreen=true&h_r=next-challenge&h_v=zen 

 

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.

 

round 써야하는 문제인 줄 알았는데 round 쓰면 오류난다,,,

floor로 써줘야 함

 

SELECT B.CONTINENT, floor(AVG(A.POPULATION))
FROM CITY A
INNER JOIN COUNTRY B
ON A.COUNTRYCODE = B.CODE
GROUP BY B.CONTINENT;
728x90