Algorithm/SQL
[SQL][HackerRank]African Cities
융무
2020. 6. 13. 16:46
https://www.hackerrank.com/challenges/african-cities/problem?h_r=next-challenge&h_v=zen
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.
Input Format
The CITY and COUNTRY tables are described as follows:
- join two tables ==> FROM CITY AS i JOIN COUNTRY AS o ON i.COUNTRYCODE=o.CODE
- query names of all cities ==> SELECT i.NAME
- where the Continent is ‘Africa’ ==> WHERE o.CONTINENT=‘Africa’
SELECT I.NAME
FROM CITY AS I
JOIN COUNTRY AS O ON I.COUNTRYCODE = O.CODE
WHERE O.CONTINENT = 'Africa';