티스토리 뷰
[MySQL/Hackerrank] Population Census, African Cities, Average Population of Each Continent
hoojiv 2021. 11. 3. 10:01Population Census
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(A.population)
FROM CITY A
JOIN COUNTRY B
ON A.CountryCode = B.Code
WHERE B.CONTINENT = 'Asia';
African Cities
Given the CITY and COUNTRY tables, query the names of all cities where the CONTINENT is 'Africa'.
Note: CITY.CountryCode and COUNTRY.Code are matching key columns.
Input Format
The CITY and COUNTRY tables are described as follows:
SELECT A.NAME
FROM CITY A
JOIN COUNTRY B
ON A.CountryCode = B.Code
WHERE B.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.
Note: CITY.CountryCode and COUNTRY.Code are matching key columns.
Input Format
The CITY and COUNTRY tables are described as follows:
SELECT B.Continent, TRUNCATE(AVG(A.Population),0)
FROM CITY A
JOIN COUNTRY B
ON A.CountryCode = B.CODE
GROUP BY B.Continent
'Programming > MySQL' 카테고리의 다른 글
[MySQL/Hackerrank] Top Competitors (0) | 2021.11.03 |
---|---|
[MySQL/Hackerrank] The Report (0) | 2021.11.03 |
[MySQL/Hackerrank] Weather Observation Station 2~20 (0) | 2021.11.03 |
[MySQL/Hackerrank] Revising Aggregations (0) | 2021.11.03 |
[MySQL/Hackerrank] New Companies (0) | 2021.11.02 |
- Total
- Today
- Yesterday
- 동국알앤에스
- list
- 에코캡
- 넷플릭스
- 넥스트BT
- 코로나19
- 매매일지
- 해커랭크
- Tableau
- SQL Server
- 테슬라
- Weather Observation Station
- 대원화성
- python
- hackerrank
- 분석탭
- python3
- string
- 미중무역전쟁
- 리비안
- TSQL
- HK이노엔
- mysql
- DATABASE
- 몰누피라비르
- tensorflow
- MSSQL
- insert
- MS SQL Server
- 경구치료제
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |