개인공부/SQL

[SQL]해커랭크 Population Census 문제 풀이

k솔이 2023. 4. 22. 18:06

문제>

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.

 

즉,  COUNTRY.continent = ''Asia 인 CITY.population 의 합을 조회해라.

COUNTRY.Code 와 CITY.CountryCode 키 매칭

 

 

SELECT SUM(B.population)
FROM COUNTRY A
	INNER JOIN CITY B ON A.Code = B.CountryCode
WHERE A.CONTINENT = 'Asia'