SQL 문제풀이
[해커랭크 SQL] Basic Join - Average Population of Each Continent
냄비짱
2023. 8. 23. 00:03
728x90
❓ Question
https://www.hackerrank.com/challenges/average-population-of-each-continent
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
❗ Answer
SELECT country.continent, FLOOR(AVG(city.population))
FROM city
INNER JOIN country
ON city.countrycode = country.code
GROUP BY country.continent;
📌 Discussion
- join 후 group by로 continent별로 묶고 avg 집계 후 floor로 버림