알고리즘/HackerRank
[HackerRank] Average Population of Each Continent 오라클 풀이
mndev
2024. 1. 31. 16:02
문제링크
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
풀이
1. 평균 인구수 구하고, 내림을 위해 floor 함수 사용
2. code를 기준으로 조인
3. continent를 기준으로 그룹화
코드
select b.continent, floor(avg(a.population))
from city a join country b
on a.countrycode = b.code
group by b.continent;