African Cities

AGGREGATION

Question Link

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 table is described as follows:

The COUNTRY table IS described as follows:

SELECT 
    c.name
FROM City c
LEFT JOIN Country cy
ON c.countrycode = cy.code
WHERE cy.continent = 'Africa'

-- or filter first
SELECT c.name
FROM city c
JOIN (SELECT code FROM country WHERE continent='Africa') cy
ON c.countrycode = cy.code

Last updated