Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created October 25, 2020 11:14
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/97a1739fdd9a5679e59ffa6be9936cb4 to your computer and use it in GitHub Desktop.
Save codecademydev/97a1739fdd9a5679e59ffa6be9936cb4 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:
-- Returns the largest population in Gabon in the dataset
SELECT MAX(population)
FROM population_years
WHERE country = 'Gabon';
-- Returns the 10 lowest population countries and their population in 2005 and sorts in ascending order
SELECT country, population
FROM population_years
WHERE year = 2005
ORDER BY population ASC
LIMIT 10;
-- Returns all countries and their population where population is over 100m in 2010 and sorts in asecending order
SELECT DISTINCT country, population
FROM population_years
WHERE year = 2010
AND population > 100
ORDER BY population ASC;
-- Counts how many countries in the dataset have "Islands" anywhere in the name
SELECT COUNT(DISTINCT(country))
FROM population_years
WHERE country LIKE "%Islands%";
-- Returns population of Indonesia in 2000 and 2010
SELECT *
FROM population_years
WHERE (year = 2000 OR year = 2010)
AND country = "Indonesia";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment