Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created February 7, 2020 09:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save codecademydev/f1d59aec40dd3a5516a868ee65e47c58 to your computer and use it in GitHub Desktop.
Codecademy export
select count(*)
from countries
where continent = 'Africa';
select sum(population_years.population)
from population_years
join countries
on population_years.country_id = countries.id
where population_years.year = 2005
and countries.continent = 'Oceania';
select round(avg(population_years.population),2) as 'Average Population in South America 2003'
from population_years
join countries
on population_years.country_id = countries.id
where population_years.year = 2003
and countries.continent = 'South America';
select min(population_years.population) as 'Population',countries.name
from population_years
join countries
where population_years.year = 2007;
select round(avg(population_years.population),2) as 'Avg Population in Poland'
from population_years
join countries
on population_years.country_id = countries.id
where countries.name = 'Poland';
select distinct name, count(*)
from countries
where name like '%The%';
SELECT DISTINCT countries.name
FROM countries
JOIN population_years
ON countries.id=population_years.country_id
WHERE countries.name LIKE '%The%';
select sum(population_years.population),countries.continent
from population_years
join countries
on population_years.country_id = countries.id
where population_years.year = 2010
group by 2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment