-
-
Save codecademydev/4eca9bd6608c188491a3e4af39671f0c to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH total AS ( | |
SELECT * | |
FROM population_years | |
JOIN countries | |
ON population_years.country_id = countries.id | |
) | |
-- 3 | |
SELECT COUNT(*) | |
FROM countries | |
WHERE continent = 'Africa'; | |
-- 4 | |
SELECT SUM(population) | |
FROM total | |
WHERE year == 2005 | |
AND continent == 'Oceania'; | |
-- 5 | |
SELECT AVG(population) | |
FROM total | |
WHERE year == 2003 | |
AND continent == 'South America'; | |
--6 | |
SELECT name, MIN(population) | |
FROM total | |
WHERE year = 2007; | |
--7 | |
SELECT SUM(population) | |
FROM total | |
WHERE name == 'Poland'; | |
--8 | |
SELECT name | |
FROM total | |
WHERE name LIKE '%the%' | |
GROUP BY name; | |
--9 | |
SELECT continent, SUM(population) | |
FROM total | |
WHERE year == 2010 | |
GROUP BY continent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment