πλ³Έ ν¬μ€ν
μμ μ¬μ©λλ ν
μ΄λΈμ μλ£μ μΆμ²λ HackerRank μμ λ°νλλ€.
https://www.hackerrank.com/challenges/average-population-of-each-continent/problem?isFullScreen=false
π쑰건
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.
μ£Όμ΄μ§ CITYμ COUNTRY ν μ΄λΈμμ λͺ¨λ λλ₯λ€μ μ΄λ¦κ³Ό κ° λλ₯μ νκ· λμ μΈκ΅¬ μλ₯Ό 쿼리ν΄λΌ. κ·Έλ¦¬κ³ νκ· λμ μΈκ΅¬ μλ κ°μ₯ κ°κΉμ΄ μ μλ‘ λ΄λ¦Όνμ¬ ννν΄λΌ.
SELECT COUNTRY.CONTINENT, FLOOR(AVG(CITY.POPULATION))
FROM CITY
INNER JOIN COUNTRY
ON CITY.COUNTRYCODE = COUNTRY.CODE
GROUP BY COUNTRY.CONTINENT;
πλ¬Έμ ν΄κ²°μ μν μμ΄λμ΄
SELECT COUNTRY.CONTINENT, TRUNCATE(AVG(CITY.POPULATION),0)
FROM CITY
INNER JOIN COUNTRY
ON CITY.COUNTRYCODE = COUNTRY.CODE
GROUP BY COUNTRY.CONTINENT;