Practice > SQL > Basic Join > Asian Population

Problem

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.
문제링크

Answer

SELECT SUM(CITY.POPULATION) -- WHERE로 원하는 ASIA 값만 나왔기 때문에 여기서는 GROUP BY를 사용하지 않아도됨
FROM CITY
    INNER JOIN COUNTRY ON CITY.CountryCode = COUNTRY.Code
WHERE COUNTRY.CONTINENT = 'ASIA'
-- LEFT JOIN해도 답이 똑같음

0개의 댓글