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:

1 Like

My solution :smiley:

Sharing my solution. Let me know if you find something I could have done differently or better!

Here’s my solution, as well. There are so many different solutions here!

https://gist.github.com/03355d20322b0f0ae15571ac3bfa824d

Hello Everybody.
this is my first Challenge Project on Codecademy.
May it be useful first for me second for you.
Thanks.

Test me!

– This is the first query:

– SELECT DISTINCT country from population_years;

– Add your additional queries below:

– select population from population_years where year = 2005 order by population asc limit 10;

– select country, count() from population_years group by country;

– select DISTINCT country from population_years where population > 10;

– select count(DISTINCT country) from population_years where country like ‘%Islands%’;

select country, population, year from population_years where country =‘Indonesia’ ;


Here is my code and I hope it is helpful! let me know if there is any question.