Prepare > SQL > Basic Join > African Cities
2023. 5. 24. 22:24ㆍHackerRank-My SQL
African Cities | HackerRank
Query the names of all cities on the continent 'Africa'.
www.hackerrank.com
문제
Given the CITY and COUNTRY tables, query the names of all cities where the CONTINENT is 'Africa'.
Note: CITY.CountryCode and COUNTRY.Code are matching key columns.
=> CITY와 COUNTRY에서 아프리카 대륙의 도시 이름을 쿼리하라. 매칭키 주어짐.
코드
SELECT CITY.NAME
FROM CITY
INNER JOIN COUNTRY ON CITY.COUNTRYCODE = COUNTRY.CODE
WHERE CONTINENT = 'Africa';
노트
SELECT CT.NAME FROM CITY AS CT
LEFT JOIN COUNTRY AS CN ON CT.COUNTRYCODE = CN.CODE
WHERE CN.CONTINENT = 'Africa';
두 번째 시도
SELECT CT.NAME
FROM CITY AS CT INNER JOIN COUNTRY AS CN ON CT.COUNTRYCODE = CN.CODE
WHERE CN.CONTINENT = 'Africa';
- 아직 살아있구만
'HackerRank-My SQL' 카테고리의 다른 글
Prepare > SQL > Basic Join > Population Census (0) | 2023.05.25 |
---|---|
Prepare > SQL > Basic Join > Average Population of Each Continent (0) | 2023.05.24 |
Prepare > SQL > Advanced Select > Binary Tree Nodes (0) | 2023.05.23 |
Prepare > SQL > Aggregation > Weather Observation Station 19 (0) | 2023.05.22 |
Prepare > SQL > Aggregation > Weather Observation Station 18 (0) | 2023.05.20 |