Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created February 2, 2020 07:40
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/c82d140fdf02e4878e3c488fb418b97b to your computer and use it in GitHub Desktop.
Save codecademydev/c82d140fdf02e4878e3c488fb418b97b to your computer and use it in GitHub Desktop.
Codecademy export
SELECT COUNT(*)
FROM countries
WHERE continent = 'Africa';
SELECT SUM(population)
FROM population_years
JOIN countries
ON population_years.country_id = countries.id
WHERE continent = 'Oceania' AND year = 2005;
SELECT AVG(population)
FROM population_years
JOIN countries
ON population_years.country_id = countries.id
WHERE continent = 'South America' AND year = 2003;
SELECT name
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE year = 2007
ORDER BY population ASC
LIMIT 1;
SELECT AVG(population)
FROM population_years
JOIN countries
ON population_years.country_id = countries.id
WHERE name = 'Poland';
SELECT DISTINCT countries.name
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE countries.name LIKE '%The%';
SELECT SUM(population),countries.continent
FROM population_years
JOIN countries
ON population_years.country_id = countries.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