Skip to content

Instantly share code, notes, and snippets.

@MrN00b0t
Last active May 1, 2020 10:24
Show Gist options
  • Save MrN00b0t/c9edcd3dfc4499aa5e669655079e6d03 to your computer and use it in GitHub Desktop.
Save MrN00b0t/c9edcd3dfc4499aa5e669655079e6d03 to your computer and use it in GitHub Desktop.
Codecademy: World Populations SQL Practice Solution
-- This is the first query:
SELECT DISTINCT year from population_years;
-- Add your additional queries below:
SELECT ROUND(MAX(population), 2) AS 'Largest Population of Gabon in Dataset (mil)'
FROM population_years
WHERE country = 'Gabon';
SELECT country AS 'Countries with Smallest Populations in 205 (Ascending)'
FROM population_years
WHERE year = 2005
ORDER BY 1 ASC
LIMIT 10;
SELECT DISTINCT country AS "Countries with Populations over 100 mil in 2010"
FROM population_years
WHERE population > 100 AND year =2010;
SELECT DISTINCT country AS 'Countries with the word "Islands" in their name'
FROM population_years
WHERE country LIKE '%Islands%';
SELECT year, ROUND(population, 2) AS 'Population of Indonesia (mil)'
FROM population_years
WHERE country = 'Indonesia' AND (year = 2000 OR year = 2010);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment