Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created March 16, 2020 02:41
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/f9a45c6668b27f7353440d8debfbaeb1 to your computer and use it in GitHub Desktop.
Save codecademydev/f9a45c6668b27f7353440d8debfbaeb1 to your computer and use it in GitHub Desktop.
Codecademy export
select *
from countries
limit 10;
select *
from population_years
limit 5;
select count(*)
from countries
where continent='Africa';
select year, sum(population), countries.continent
FROM population_years
JOIN countries
on population_years.country_id = countries.id
WHERE population_years.year = 2005
AND countries.continent = 'Oceania';
select year, avg(population), countries.continent
FROM population_years
join countries
on population_years.country_id = countries.id
WHERE population_years.year = 2003
AND countries.continent = 'South America';
select year, min(population), countries.name
from population_years
join countries
on population_years.country_id = countries.id
WHERE population_years.year = 2007;
select countries.name, avg(population)
from population_years
join countries
on population_years.country_id = countries.id
WHERE countries.name = 'Poland';
select count(*)
from countries
WHERE name like '%the%';
select year, sum(population), countries.continent
FROM population_years
JOIN countries
on population_years.country_id = countries.id
WHERE population_years.year = 2010
group by countries.continent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment