Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created February 29, 2020 11:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/f082fe326f05d318048c11a40bcced06 to your computer and use it in GitHub Desktop.
Save codecademydev/f082fe326f05d318048c11a40bcced06 to your computer and use it in GitHub Desktop.
Codecademy export
SELECT COUNT(*)
FROM countries
where continent = 'Africa';
SELECT SUM(population_years.population) AS 'Population', countries.continent AS 'Oceania'
FROM population_years
JOIN countries
ON population_years.country_id=countries.id
WHERE countries.continent = 'Oceania'
AND population_years.year = '2005';
SELECT ROUND(AVG(population_years.population),1) AS 'Average population', population_years.year, countries.continent AS 'South America'
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE continent = 'South America'
AND year = '2003';
SELECT MIN(population_years.population) AS 'Population', countries.name AS 'Country with smallest population'
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE year = '2007';
SELECT ROUND(AVG(population_years.population), 1), countries.name
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE name = 'Poland';
SELECT COUNT(*)
FROM countries
WHERE name LIKE '%The%';
SELECT ROUND(SUM(population_years.population),1) AS 'Avarage population', countries.continent AS 'Continents'
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE year = '2010'
GROUP BY continent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment