Skip to content

Instantly share code, notes, and snippets.

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