diff --git a/02_select_from_world_tutorial.sql b/02_select_from_world_tutorial.sql index ae12da3..0b3721b 100644 --- a/02_select_from_world_tutorial.sql +++ b/02_select_from_world_tutorial.sql @@ -30,3 +30,44 @@ WHERE name IN ('France', 'Germany', 'Italy') SELECT name country FROM world WHERE name LIKE '%United%' + +-- 7. Show the countries that are big by area or big by population. +-- Show name, population and area. +SELECT name, population, area +FROM world +WHERE area > 3000000 OR population > 250000000 + +-- 8. Show the countries that are big by area or big by population but not both. +-- Show name, population and area. +SELECT name, population, area +FROM world +WHERE area > 3000000 XOR population > 250000000 + +-- 9. For South America show population in millions and GDP in billions both to 2 +-- decimal places. +SELECT name, ROUND(population/1000000, 2), ROUND(GDP/1000000000, 2) +FROM world +WHERE continent = 'South America' + +-- 10. Show per-capita GDP for the trillion dollar countries to the nearest $1000. +SELECT name, ROUND(GDP/population, -3) +FROM world +WHERE GDP >= 1000000000000 + +-- 11. Show the name and capital where the name and the capital have the same number +-- of characters. +SELECT name, capital +FROM world +WHERE LENGTH(name) = LENGTH(capital) + +-- 12. Show the name and the capital where the first letters of each match. Don't +-- include countries where the name and the capital are the same word. +SELECT name, capital +FROM world +WHERE LEFT(name, 1) = LEFT(capital,1) AND name <> capital + +-- 13. Find the country that has all the vowels and no spaces in its name. +SELECT name +FROM world +WHERE name NOT LIKE '% %' AND name LIKE '%a%' AND name LIKE '%e%' AND name LIKE '%i%' + AND name LIKE '%o%' AND name LIKE '%u%'