-
-
Save codecademydev/e57d49175cb59e57369e66d4dc424886 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'; | |
--COUNT (*) 56 | |
SELECT SUM(population) | |
FROM population_years | |
JOIN countries | |
ON population_years.country_id = countries.id | |
WHERE population_years.year = 2005 | |
AND countries.continent = 'Oceania'; | |
--SUM(population)32.66417 | |
SELECT AVG(population) | |
FROM population_years | |
JOIN countries | |
ON population_years.country_id = countries.id | |
WHERE population_years.year = 2003 | |
AND countries.continent = 'South America'; | |
--AVG(population) 25.8906514285714 | |
SELECT countries.name, MIN(population) | |
FROM population_years | |
JOIN countries | |
ON population_years.country_id = countries.id | |
WHERE population_years.year = 2007; | |
--Niue MIN(population) 0.00216 | |
SELECT AVG(population) | |
FROM population_years | |
JOIN countries | |
ON population_years.country_id = countries.id | |
WHERE countries.name = 'Poland'; | |
--AVG(population) 38.5606790909091 | |
SELECT COUNT(*) | |
FROM countries | |
WHERE countries.name LIKE '%The%'; | |
--COUNT(*) 2 Bahamas, The Gambia, The or 4 Netherlands Antilles, Netherlands | |
SELECT countries.continent, SUM(population) | |
FROM population_years | |
JOIN countries | |
ON population_years.country_id = countries.id | |
WHERE population_years.year = 2010 | |
GROUP BY continent; | |
--Africa 1015.47846 Asia 4133.09148 Europe 723.06044 North America 539.79456 Oceania 34.95696 South America 396.58235 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment