Answers to the SELECT from WORLD tutorial on SQLzoo.
1. Just run the query
2. Show the name for the countries that have a population of at least 200 million. (200 million is 200000000, there are eight zeros)
SELECT name FROM world WHERE population>=200000000
3. Give the name and the per capita GDP for those countries with a population of at least 200 million.
SELECT name, gdp/population as PerCapGDP FROM world WHERE population >= 200000000
4. Show the name
and population
in millions for the countries of ‘South America’ Divide the population by 1000000 to get population in millions.
SELECT name, ROUND(population/1000000,2) as scaledPop FROM world WHERE continent = 'South America'
NOTE: The ROUND() is not necessary, but I found it good practice. The 2 within the brackets is the number of decimal places it should round to.
5. Show the name
and population
for ‘France’, ‘Germany’, ‘Italy’
SELECT name, population FROM world WHERE name in ('France', 'Germany', 'Italy')
6. Identify the countries which have names including the word ‘United’
SELECT name FROM world WHERE name LIKE '%United%'