World Populations Challenge Project (SQL)

– This is the first query:

SELECT DISTINCT year from population_years;

– Add your additional queries below:

SELECT DISTINCT country, population FROM population_years WHERE country = ‘Gabon’ ORDER BY population DESC;

SELECT country, population FROM population_years WHERE year = 2005 ORDER BY population ASC;

SELECT DISTINCT * FROM population_years WHERE population > 100 AND year = 2010;

SELECT DISTINCT country FROM population_years WHERE country LIKE ‘%Islands%’;

SELECT country, population, year FROM population_years WHERE country = ‘Indonesia’ AND year BETWEEN 2000 AND 2010;

I like how you did the final OR to get 2000 and 2010.

1 Like

Compared my solution to the one given above, MAX/MIN function can be used to identify country with least or maximum population in place of order by and limit function.

Haven’t figured it out, but perhaps there exists a solution that can directly perform arithmetic operation on the numerical query results, reducing the length of the query .

Based on the material us newbies covered and the examples from the some of the solutions offered above, I see there are a lot more elegant ways of achieving some results.

Task 4 - What is the largest population size:?
Using SELECT MAX() instead of ORDERING BY and LIMIT 1

Task 7 - How many countries with the word ‘island’ ?
SELECT DISTINCT COUNT instead of listing all distinct countries and manually counting.

Very cool. Thanks.

Task 8 - Population difference of Indonesia 2000-2010?
Haven’t scrolled far enough to find how to implement simple arithmetics, but hoping to cover those soon :slight_smile: