Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created September 13, 2020 12:50
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/09eb7aefed5a28bd3d182719ba3337f7 to your computer and use it in GitHub Desktop.
Save codecademydev/09eb7aefed5a28bd3d182719ba3337f7 to your computer and use it in GitHub Desktop.
Codecademy export
SELECT COUNT(*) AS 'total countries from Africa'
FROM countries
WHERE continent = 'Africa';
SELECT SUM(population) AS 'total population of the Oceania continent in 2005'
FROM countries
INNER JOIN population_years
ON countries.id = population_years.country_id
WHERE countries.continent = 'Oceania'
AND population_years.year = '2005';
SELECT AVG(population) AS 'average population of South American countries in 2003'
FROM countries
INNER JOIN population_years
ON countries.id = population_years.country_id
WHERE countries.continent = 'South America'
AND population_years.year = '2003';
SELECT name AS 'country with the smallest population', MIN(population) AS 'population'
FROM countries
INNER JOIN population_years
ON countries.id = population_years. country_id;
SELECT AVG(population) AS 'Average population of Poland 2000-2010'
FROM population_years
INNER JOIN countries
ON population_years.country_id = countries.id
WHERE name = 'Poland';
SELECT name AS 'countries with "The"'
FROM countries
WHERE name LIKE '%The';
SELECT SUM(population) AS 'total population of all countries'
FROM population_years
WHERE year = '2010';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment