Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created May 13, 2020 04:30
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/342b5d86e67fa65272db164470b74990 to your computer and use it in GitHub Desktop.
Save codecademydev/342b5d86e67fa65272db164470b74990 to your computer and use it in GitHub Desktop.
Codecademy export
SELECT SUM(population)
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE continent = 'Oceania';
SELECT SUM(population)
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE continent = 'Oceania' AND year = 2005;
SELECT AVG(population)
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE continent = 'South America' AND year = 2003;
SELECT name
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE population IS NOT NULL
ORDER BY population
LIMIT 1;
SELECT AVG(population)
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE name = 'Poland';
SELECT COUNT(*)
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE name LIKE '% The';
SELECT continent, SUM(population)
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE year = 2010
GROUP BY continent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment