Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created September 3, 2020 04:56
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/6c3ef9ecbe850230a76180cd6a05a195 to your computer and use it in GitHub Desktop.
Save codecademydev/6c3ef9ecbe850230a76180cd6a05a195 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 of Oceania in 2005'
FROM population_years
JOIN countries
ON population_years.country_id = countries.id
WHERE continent = 'Oceania' and year = 2005;
SELECT ROUND(AVG(population_years.population))
AS 'Avg. Population of South America in 2003'
FROM population_years
JOIN countries
ON population_years.country_id = countries.id
WHERE continent = "South America" AND year = 2003;
SELECT MIN(population_years.population)
AS 'Smallest population in 2007',
countries.name
FROM population_years
JOIN countries
ON population_years.country_id = countries.id
WHERE year = 2007;
SELECT AVG(population_years.population)
AS 'Avg. Population in Poland'
FROM population_years
JOIN countries
ON population_years.country_id = countries.id
WHERE name = "Poland";
SELECT COUNT(*)
FROM countries
WHERE name LIKE "%The%";
SELECT countries.continent,
ROUND(SUM(population_years.population), 2)
AS 'Total population per continent in 2003'
FROM population_years
JOIN countries
ON population_years.country_id = countries.id
WHERE 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