Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created September 29, 2020 11:05
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/4ab08a262c7c3f94e1f02019e1ca4772 to your computer and use it in GitHub Desktop.
Save codecademydev/4ab08a262c7c3f94e1f02019e1ca4772 to your computer and use it in GitHub Desktop.
Codecademy export
SELECT COUNT(*)
FROM countries
WHERE continent = 'Africa';
SELECT SUM(population_years.population) AS 'total population in Oceania at 2005'
FROM population_years
JOIN countries
ON population_years.country_id = countries.id
WHERE year = '2005'
AND countries.continent = 'Oceania';
SELECT AVG(population_years.population) AS 'average population in South America at 2003'
FROM population_years
JOIN countries
ON population_years.country_id = countries.id
WHERE year = '2003'
AND countries.continent = 'South America';
SELECT MIN(countries.name) AS 'Country with less population'
FROM population_years
JOIN countries
ON population_years.country_id = countries.id
WHERE population_years.year = '2007';
SELECT AVG(population_years.population) AS 'Average population Poland through time'
FROM population_years
JOIN countries
ON population_years.country_id = countries.id
WHERE countries.name = 'Poland';
SELECT COUNT(*)
FROM population_years
JOIN countries
ON population_years.country_id = countries.id
WHERE countries.name LIKE '%The%';
SELECT DISTINCT countries.continent, SUM(population_years.population) AS 'total_population_per_continent'
FROM population_years
JOIN countries
ON population_years.country_id = countries.id
GROUP BY countries.continent
ORDER BY total_population_per_continent DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment