-
Notifications
You must be signed in to change notification settings - Fork 0
/
0_select_basics.sql
34 lines (31 loc) · 1.33 KB
/
0_select_basics.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
-- Exercise reference: https://sqlzoo.net/wiki/SELECT_basics
-- Notes about table(make sure you included the last dot in the adress):
-- https://sqlzoo.net/wiki/Read_the_notes_about_this_table.
-- -----------------------------------------------------------------
-- Table sample:
--
-- world
-- | name | continent | area | population | gdp |
-- | ----------- | --------- | ------- | ---------- | ------------ |
-- | Afghanistan | Asia | 652230 | 25500100 | 20343000000 |
-- | Albania | Europe | 28748 | 2831741 | 12960000000 |
-- | Algeria | Africa | 2381741 | 37100000 | 188681000000 |
-- | Andorra | Europe | 468 | 78115 | 3712000000 |
-- | Angola | Africa | 1246700 | 20609294 | 100990000000 |
-- ...
-- -----------------------------------------------------------------
-- Show the population of Germany.
SELECT population
FROM world
WHERE name = 'Germany';
-- Show the name and the population for 'Sweden', 'Norway' and 'Denmark'.
SELECT name
,population
FROM world
WHERE name IN ('Sweden', 'Norway', 'Denmark');
-- Show the country and the area for countries
-- with an area between 200,000 and 250,000.
SELECT name
,area
FROM world
WHERE area BETWEEN 200000 AND 250000;