-
-
Save codecademydev/17d3f9e4a136f2a5b066f721d4149675 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
SELECT COUNT(*) | |
FROM countries | |
WHERE continent = 'Africa'; | |
--4. What was the total population of the continent of Oceania in 2005? | |
SELECT SUM(p.population) | |
FROM population_years p | |
JOIN countries c | |
ON p.country_id = c.id | |
WHERE c.continent = 'Oceania' AND | |
p.year = 2005; | |
-- 5. What is the average population of countries in South America in 2003? | |
SELECT AVG(population) | |
FROM population_years p | |
JOIN countries c | |
ON p.country_id = c.id | |
WHERE c.continent = 'South America' AND | |
p.year = 2003; | |
-- 6.What country had the smallest population in 2007? | |
SELECT MIN(population) | |
FROM population_years p | |
JOIN countries c | |
ON p.country_id = c.id | |
WHERE p.year = 2007; | |
-- 7. What is the average population of Poland during the time period covered by this dataset? | |
SELECT AVG(population) | |
FROM population_years p | |
JOIN countries c | |
ON p.country_id = c.id | |
WHERE c.name = 'Poland'; | |
-- 8. How many countries have the word “The” in their name? | |
SELECT COUNT(*) | |
FROM countries | |
WHERE name LIKE '%The%'; | |
SELECT c.continent, SUM(p.population) | |
FROM population_years p | |
JOIN countries c | |
ON p.country_id = c.id | |
WHERE p.year = 2010 | |
GROUP BY c.continent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment