Algorithm & SQL/SQL
Population Census - BASIC JOIN
YoonJong
2022. 6. 9. 16:46
728x90
반응형
SQL join 문을 문제를 풀면서 연습하고 싶어서 join 문제를 풀어보았다.
city 테이블과 country 테이블이 2개 존재하며,
continent 가 asia 인 인구수를 구하는 문제이다.
join할 수 있는 key는 city 테이블의 countrycode 와 country 의 code 이다.
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(city.population) from city inner join country on city.countrycode = country.code
where country.continent = 'asia'
728x90
반응형