-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSQL-queries.sql
26 lines (23 loc) · 980 Bytes
/
SQL-queries.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
/*
This file display the commands used to download the CSV files from the online database using SQL.
*/
-- Find the nearest city which is Singapore
SELECT *
FROM city_list
WHERE city LIKE 'Singapore';
/*
Extract both Singapore and global data by joining the 2 tables and
create new columns for the respective average temperature.
*/
SELECT global_data.year, city_data.city, city_data.avg_temp AS Singapore, global_data.avg_temp AS Global
FROM city_data JOIN global_data
ON city_data.year = global_data.year
WHERE city_data.city LIKE 'Singapore';
/*
There were missing average temperature data for Singapore from year 1825 to 1838. The missing data
were removed for this project for better analysis result.
*/
SELECT global_data.year, city_data.city, city_data.avg_temp AS Singapore, global_data.avg_temp AS Global
FROM city_data JOIN global_data
ON city_data.year = global_data.year
WHERE city_data.city LIKE 'Singapore' AND global_data.year > 1838;