티스토리 뷰
[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
- 리비안
- 넷플릭스
- TSQL
- 미중무역전쟁
- 해커랭크
- 동국알앤에스
- 대원화성
- mysql
- MS SQL Server
- Weather Observation Station
- HK이노엔
- 코로나19
- python3
- list
- 경구치료제
- 에코캡
- 분석탭
- MSSQL
- 넥스트BT
- python
- SQL Server
- DATABASE
- 매매일지
- insert
- hackerrank
- Tableau
- 테슬라
- string
- 몰누피라비르
- tensorflow
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |