-
Notifications
You must be signed in to change notification settings - Fork 0
/
global_situation.sql
67 lines (58 loc) · 1.62 KB
/
global_situation.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
What was the total forest area (in sq km) of the world in 1990?
Please keep in mind that you can use the country record denoted as
“World" in the region table.
*/
SELECT country_name, year, forest_area_sqkm
FROM forestation
WHERE country_name = 'World' AND year = 1990;
/*
What was the total forest area (in sq km) of the world in 2016?
Please keep in mind that you can use the country record in the table is
denoted as “World.”
*/
SELECT country_name, year, forest_area_sqkm
FROM forestation
WHERE country_name = 'World' AND year = 2016;
/*
What was the change (in sq km) in the forest area of the world from 1990 to 2016?
*/
SELECT (
(SELECT forest_area_sqkm
FROM forestation
WHERE country_name = 'World'
AND year = 1990) -
(SELECT forest_area_sqkm
FROM forestation
WHERE country_name = 'World'
AND year = 2016)) AS diff
FROM forestation;
/*
What was the percent change in forest area of the world between 1990 and 2016?
*/
SELECT (((
(SELECT forest_area_sqkm
FROM forestation
WHERE country_name = 'World'
AND year=1990) -
(SELECT forest_area_sqkm
FROM forestation
WHERE country_name = 'World'
AND year=2016)) / (
(SELECT forest_area_sqkm
FROM forestation
WHERE country_name = 'World'
AND year=1990))) *100) AS perc_dicrease
FROM forestation;
/*
If you compare the amount of forest area lost between 1990 and 2016,
to which country's total area in 2016 is it closest to?
*/
SELECT country_name,
year,
total_area_sqkm
FROM forestation
WHERE year = 2016
AND total_area_sqkm <= 1324449
ORDER BY total_area_sqkm DESC
LIMIT 1;