Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created March 25, 2020 20:36
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/50738a2969960c9f493f1db59faaf9a0 to your computer and use it in GitHub Desktop.
Save codecademydev/50738a2969960c9f493f1db59faaf9a0 to your computer and use it in GitHub Desktop.
Codecademy export
-- This is the first query:
SELECT DISTINCT year from population_years;
-- Add your additional queries below:
-- Selects largest population size for Gabon in dataset
select *
from population_years
where country = 'Gabon'
order by population desc
limit 1;
-- Selects 10 lowest population countries in 2005
select *
from population_years
where year = 2005
order by population asc
limit 10;
-- Selects all distinct countries with a population over 100 million in 2010
select distinct country
from population_years
where population > 100 and year = 2010;
-- Counts all countries that have the word "Islands" in their name
select count (distinct country)
from population_years
where country like '%Islands%';
-- Selects population in Indonesia between 2000 and 2010
select *
from population_years
where country = 'Indonesia'
and year in (2000, 2010);
-- 242.96834 - 214.67661 = 28.29173 million
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment