https://www.hackerrank.com/challenges/asian-population/problem
Asian Population | HackerRank
Query the sum of the populations of all cities on the continent 'Asia'.
www.hackerrank.com
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:


- join two tables on countrycode ==> FROM CITY AS i JOIN COUNTRY AS o ON i.COUNTRYCODE=o.CODE
- query sum of populations of cities ==> SELECT SUM(i.POPULATION)
- where Continent is ‘Asia’ ==> WHERE o.CONTINENT=‘Asia’
<sql />
SELECT SUM(C.POPULATION)
FROM CITY AS C
JOIN COUNTRY AS O ON C.COUNTRYCODE = O.CODE
WHERE O.CONTINENT = 'Asia';
'Algorithm > SQL' 카테고리의 다른 글
[SQL][HackerRank] Average Population of Each Continent (0) | 2020.06.13 |
---|---|
[SQL][HackerRank]African Cities (0) | 2020.06.13 |
[SQL][HackerRank] The Report (0) | 2020.06.12 |
[SQL][HackerRank] Weather Observation Station 16 (0) | 2020.06.12 |
[SQL][HackerRank] Weather Observation Station 15 (0) | 2020.06.12 |