Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created February 28, 2020 19:54
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/8c7d71498a1ed9d76cf5c6d61e0b72c9 to your computer and use it in GitHub Desktop.
Save codecademydev/8c7d71498a1ed9d76cf5c6d61e0b72c9 to your computer and use it in GitHub Desktop.
Codecademy export
SELECT COUNT(*) FROM countries
WHERE continent='Africa';
SELECT SUM(population)
FROM countries
LEFT JOIN population_years pop
ON countries.id=pop.country_id
WHERE continent='Oceania' AND year=2005;
SELECT AVG(population)
FROM countries
LEFT JOIN population_years pop
ON countries.id=pop.country_id
WHERE continent='South America' AND year=2003;
SELECT name, MIN(population)
FROM countries
LEFT JOIN population_years pop
ON countries.id=pop.country_id
WHERE year=2007;
SELECT AVG(population)
FROM countries
LEFT JOIN population_years pop
ON countries.id=pop.country_id
WHERE name='Poland';
SELECT count(name)
FROM countries
WHERE name LIKE '%The%';
SELECT continent, sum(population)
FROM countries
LEFT JOIN population_years pop
ON countries.id=pop.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