CodingSpace

[HackerRank/SQL] Basic Join - Population Census 본문

HackerRank/SQL

[HackerRank/SQL] Basic Join - Population Census

개발자_조이킴 2022. 5. 26. 09:35

Problem. Basic Join - Population Census


Link.

https://www.hackerrank.com/challenges/asian-population/problem?utm_campaign=challenge-recommendation&utm_medium=email&utm_source=7-day-campaign

 

The PADS | HackerRank

Query the name and abbreviated occupation for each person in OCCUPATIONS.

www.hackerrank.com


Description.

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.

 

CITY, COUNTRY 테이블을 사용하여 CONTINENT가 'Asia'인 모든 도시의 총 인구를 조회하는 쿼리문을 작성하시오.

 

CITY 테이블
COUNTRY 테이블


Key Point. 

SUM,

 

JOIN,

 

WHERE,


My Answer. 

SELECT SUM(C.POPULATION)
FROM CITY C
    JOIN COUNTRY CO
    ON C.COUNTRYCODE = CO.CODE
WHERE CO.CONTINENT = 'Asia'

References. 

 

Comments