Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created February 7, 2020 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/0d0b3d34a9eb39a98d78858ea10a96f9 to your computer and use it in GitHub Desktop.
Save codecademydev/0d0b3d34a9eb39a98d78858ea10a96f9 to your computer and use it in GitHub Desktop.
Codecademy export
SELECT COUNT(*)
AS 'Total Countries in Africa'
FROM countries
WHERE continent = 'Africa';
SELECT SUM(population_years.population)
AS 'Total Population of Oceania (in 2005)'
FROM countries
JOIN population_years
ON countries.id =
population_years.country_id
WHERE countries.continent = 'Oceania'
AND population_years.year = 2005;
SELECT AVG(population_years.population)
AS 'Average Population of South America (in 2003)'
FROM countries
JOIN population_years
ON countries.id =
population_years.country_id
WHERE countries.continent = 'South America'
AND population_years.year = 2003;
SELECT countries.name
AS 'Smallest Country (by population)'
FROM countries
JOIN population_years
ON countries.id =
population_years.country_id
WHERE population_years.population IS NOT NULL
AND population_years.year = 2007
ORDER BY population_years.population ASC
LIMIT 1;
SELECT AVG(population_years.population)
AS 'Average Population of Poland'
FROM countries
JOIN population_years
ON countries.id =
population_years.country_id
WHERE countries.name = 'Poland';
SELECT COUNT(*)
AS 'Countries with "The" in the title'
FROM countries
WHERE name LIKE '%The%';
SELECT countries.continent
AS 'Continet Name',
SUM(population_years.population)
AS 'Total Population by Continent (in 2010)'
FROM countries
JOIN population_years
ON countries.id =
population_years.country_id
GROUP BY countries.continent
ORDER BY SUM(population_years.population) DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment