Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created September 25, 2020 14:32
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/3a5ccea0185d27d14a67c0c9ed6f26ea to your computer and use it in GitHub Desktop.
Save codecademydev/3a5ccea0185d27d14a67c0c9ed6f26ea to your computer and use it in GitHub Desktop.
Codecademy export
select count(*) from countries where continent = 'Africa';
select countries.continent, population_years.year, SUM(population_years.population) as 'Total_population'
from countries
join population_years on countries.id = population_years.country_id
where countries.continent = 'Oceania' and population_years.year = 2005;
select countries.continent, population_years.year, AVG(population_years.population) AS 'Avg_population'
from countries
join population_years on countries.id = population_years.country_id
where countries.continent = 'South America' and population_years.year = 2003;
select countries.continent, population_years.year, MIN(population_years.population) AS 'Min_population'
from countries
join population_years on countries.id = population_years.country_id
where population_years.year = 2007;
select countries.name, population_years.year, AVG(population_years.population) AS 'Avg_population'
from countries
join population_years on countries.id = population_years.country_id
where countries.name = 'Poland' group by 2 order by 2;
select name, count(*) from countries where name like '%The%' group by 1;
select countries.continent, population_years.year, SUM(population_years.population) as 'Total_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