Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created September 21, 2020 14:05
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/28d76c69db46f59e259728c56ebf66e8 to your computer and use it in GitHub Desktop.
Save codecademydev/28d76c69db46f59e259728c56ebf66e8 to your computer and use it in GitHub Desktop.
Codecademy export
select count(*) [Africa_entries]
from countries
where continent = 'Africa';
select sum(population) [total_pop]
from countries c
inner join population_years p on c.id = p.country_id
where c.continent = 'Oceania';
select avg(population) [avg_pop]
from countries c
inner join population_years p on c.id = p.country_id
where c.continent = 'South America';
select c.name, p.population
from countries c
inner join population_years p on c.id = p.country_id
where p.year = '2007'
and p.population = (select min(population) from population_years where year = '2007');
select c.name, avg(p.population) [avg_pop]
from countries c
inner join population_years p on c.id = p.country_id
where c.name = 'Poland';
select count(*) [we_countries]
from countries
where countries.name like '% The%';
select c.continent, sum(p.population) [total_pop]
from countries c
inner join population_years p on c.id = p.country_id
where p.year = '2010'
group by c.continent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment