Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created March 6, 2020 10:00
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/3f8ae3d21675f7d2f7a52f7a9701c3ce to your computer and use it in GitHub Desktop.
Save codecademydev/3f8ae3d21675f7d2f7a52f7a9701c3ce to your computer and use it in GitHub Desktop.
Codecademy export
SELECT *
FROM countries
LIMIT 5;
SELECT *
FROM population_years
LIMIT 5;
SELECT COUNT(*)
FROM countries
WHERE continent = 'Africa';
SELECT SUM(population)
FROM population_years
JOIN countries
ON population_years.country_id = countries.id
WHERE continent = 'Ocenia'
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 DISTINCT name, population, year
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE year = 2007
AND population IS NOT NULL
ORDER BY population ASC
LIMIT 1;
SELECT DISTINCT name, AVG(population)
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE name = 'Poland';
SELECT COUNT(name)
FROM countries
WHERE name LIKE '%The%';
SELECT DISTINCT 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