Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created June 24, 2020 00:29
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/84eb4bd8da440e7d2908080373e87838 to your computer and use it in GitHub Desktop.
Save codecademydev/84eb4bd8da440e7d2908080373e87838 to your computer and use it in GitHub Desktop.
Codecademy export
--3.
select count(*) AS "Countries in Africa"
from countries
where continent = 'Africa';
-- 4.
select sum(population) AS "total population in Oceania (2005)"
from countries
join population_years
on countries.id = population_years.id
where year = 2005 AND
continent = "Oceania";
--5.
select avg(population) AS "Avg South America Population in 2003"
from countries
join population_years
on countries.id = population_years.id
where year = 2003 AND
continent = "South America";
--6.
select min(population) AS "Min Population in 2007", continent
from countries
join population_years
on countries.id = population_years.id
where year = 2007 ;
--7.
select avg(population) AS "avg Poland population"
from countries
join population_years
on countries.id = population_years.id
where name = "Poland"
;
--8.
select count(*) AS "country name with THE in it"
from countries
WHERE name LIKE "%The%";
--9.
select continent, sum(population) AS "total 2010 population"
from population_years
join countries
on countries.id = population_years.id
where year = 2010
group by continent
order by 2 DESC;
--
select count( DISTINCT continent)
from countries;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment