[HackerRank MySQL] INNER JOIN 문제풀기 (Basic)
2021. 1. 5. 22:51ㆍToday I Learned.../MySQL
Asian Population
Given the CITY and COUNTRY tables, query the sum of the populations of all cities where the CONTINENT is 'Asia'.
Note: CITY.CountryCode and COUNTRY.Code are matching key columns.
Input Format
The CITY and COUNTRY tables are described as follows:
select sum(city.population)
from city inner join country on city.countrycode = country.code
where continent = 'asia'
African Cities
Given the CITY and COUNTRY tables, query the names of all cities where the CONTINENT is 'Africa'.
select city.name
from city inner join country on city.countrycode = country.code
where continent = 'africa'
Average Population of Each Continent
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.
select continent, floor(avg(city.population))
from city inner join country on city.countrycode = country.code
group by 1
문제출처: 해커랭크
'Today I Learned... > MySQL' 카테고리의 다른 글
[HackerRank MySQL] Type of Triangle (0) | 2021.01.11 |
---|---|
[HackerRank MySQL] Draw The Triangle 1 & 2 - information_schema.tables (0) | 2021.01.05 |
[HackerRank MySQL] Weather Observation Station 2, 13-17 - ROUND & TRUNCATE (Basic) (0) | 2021.01.05 |
[HackerRank MySQL] Count/Sum/Average, Ceil/Floor, Replace 문제풀기 (Basic) (0) | 2021.01.05 |
[HackerRank MySQL] ORDER BY 문제풀기 (Basic) (0) | 2021.01.05 |