Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created April 4, 2020 00:28
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/f0ba974121d53978491531877f50bac2 to your computer and use it in GitHub Desktop.
Save codecademydev/f0ba974121d53978491531877f50bac2 to your computer and use it in GitHub Desktop.
Codecademy export
SELECT COUNT(*)
FROM countries
WHERE continent = 'Africa';
SELECT SUM(population_years.population)
FROM population_years
JOIN countries
ON countries.id = population_years.country_id
WHERE population_years.year = 2005
AND countries.continent = 'Oceania';
SELECT ROUND(AVG(population_years.population), 2)
AS 'Avg S America pop'
FROM population_years
JOIN countries
ON countries.id = population_years.country_id
WHERE countries.continent = 'South America'
AND population_years.year = 2003;
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)
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE countries.name = 'Poland';
SELECT COUNT(*)
FROM countries
WHERE countries.name LIKE '%The%';
SELECT countries.continent,
ROUND(SUM(population_years.population),2)
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE population_years.year = 2010
GROUP BY 1
ORDER BY 2 DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment