Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions 02_select_from_world_tutorial.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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%'