Skip to content

Instantly share code, notes, and snippets.

@jimi008
Created September 30, 2020 15:01
Show Gist options
  • Save jimi008/8e56fc81cbef460e675a6472f5fc09e2 to your computer and use it in GitHub Desktop.
Save jimi008/8e56fc81cbef460e675a6472f5fc09e2 to your computer and use it in GitHub Desktop.
World Populations Challenge Project (SQL)
-- This is the first query:
SELECT DISTINCT year from population_years;
-- Add your additional queries below:
-- Largest Population of Gabon
SELECT Max(population) AS 'Largest Population of Gabon'
FROM population_years
WHERE country = 'Gabon';
-- 10 Smallest Countries by Population in 2005
SELECT country AS '10 Smallest Countries by Population in 2005'
FROM population_years
WHERE year = 2005
ORDER BY population ASC
LIMIT 10;
-- Countries with > 100M in 2010
SELECT DISTINCT country AS 'Countries with > 100M in 2010'
FROM population_years
WHERE population > 100 AND year = 2010;
-- Countries having word Islands
SELECT distinct country AS 'Countries having word Islands'
FROM population_years
WHERE country LIKE '%Islands%';
-- Diff in population between 2000 and 2010 in Indonesia
SELECT Max(population) - Min (population) AS 'Diff in population between 2000 and 2010'
FROM population_years
WHERE year between 2000 AND 2010
AND country = 'Indonesia';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment