Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created March 27, 2020 06:23
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/162c51a06ad40540ffd885973b24a256 to your computer and use it in GitHub Desktop.
Save codecademydev/162c51a06ad40540ffd885973b24a256 to your computer and use it in GitHub Desktop.
Codecademy export
SELECT * FROM countries
LIMIT 10;
SELECT * FROM population_years
LIMIT 10;
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 countries.id = population_years.country_id
WHERE continent = 'South America' AND year = 2003;
SELECT name, MIN(population) FROM population_years
JOIN countries
ON countries.id = population_years.country_id
WHERE year = 2007;
SELECT AVG(population) FROM population_years
JOIN countries
ON countries.id = population_years.country_id
WHERE name = 'Poland';
SELECT COUNT(*) FROM countries
WHERE name LIKE '%The%';
SELECT continent, SUM(population) FROM population_years
JOIN countries
ON countries.id = population_years.country_id
WHERE year = 2010
GROUP BY 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment