Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created June 20, 2020 19:22
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/09cc0822b40fe263bf61fe2cbcf1b997 to your computer and use it in GitHub Desktop.
Save codecademydev/09cc0822b40fe263bf61fe2cbcf1b997 to your computer and use it in GitHub Desktop.
Codecademy export
SELECT COUNT(*)
FROM countries
WHERE continent = 'Africa';
SELECT countries.continent, SUM(population_years.population)
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE population_years.year = 2005
GROUP BY countries.continent;
SELECT countries.continent, AVG(population_years.population)
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE population_years.year = 2003
GROUP BY countries.continent;
SELECT countries.name, MIN(population_years.population)
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE population_years.year = 2007;
SELECT AVG(population_years.population),countries.name
FROM population_years
JOIN countries
ON population_years.country_id = countries.id
WHERE countries.name = 'Poland';
SELECT COUNT(*)
FROM countries
WHERE name LIKE '%The%';
SELECT countries.continent, SUM(population_years.population)
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE population_years.year = 2010
GROUP BY countries.continent
ORDER BY 2 DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment