-
-
Save codecademydev/2d48511f275a5696677d77c828ec70ed to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select count(*) as 'Countries in Africa' | |
from countries | |
where continent='Africa'; | |
select round(sum(population),2) as 'Total Pop', round(avg(population),2) as 'Avg Pop', countries.continent, population_years.year | |
from population_years | |
left join countries | |
on population_years.country_id=countries.id | |
WHERE countries.continent = 'Oceania' and population_years.year = 2005 | |
OR countries.continent = 'South America' and population_years.year = 2003 | |
group by 4 | |
order by 3 desc; | |
select countries.name as 'Country', min(population) 'Population' | |
from population_years | |
join countries | |
on population_years.country_id=countries.id | |
where population_years.year = 2007; | |
select countries.name as 'Country', round(avg(population),2) as 'Avg Pop' | |
from countries | |
join population_years | |
on countries.id=population_years.country_id | |
where countries.name = 'Poland'; | |
select name | |
from countries | |
where name like '%the'; | |
select countries.continent as 'Continent', population_years.population | |
from countries | |
left join population_years | |
on countries.id=population_years.country_id | |
where population_years.year = 2010 | |
group by 1 | |
order by 2 desc; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment