-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTS_Portfolio_SQL2Query.sql
More file actions
28 lines (23 loc) · 886 Bytes
/
TS_Portfolio_SQL2Query.sql
File metadata and controls
28 lines (23 loc) · 886 Bytes
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
-- SQL Queries for Top Ranked Canadian Companies based on Revenue in 2019
-- Data acquired from TS_Portfolio_Python4
-- All data
SELECT * FROM Portfolio..CanadianCompanies
-- Ranking Companies headquartered in Toronto
SELECT *
FROM Portfolio..CanadianCompanies
WHERE Headquarters = 'Toronto'
-- Ranking all Canadian Banks from least valuable to most
SELECT Name, Headquarters, value
FROM Portfolio..CanadianCompanies
WHERE Industry='Banking'
ORDER BY value ASC
-- Ranking all industries by combined revenue
SELECT Industry, SUM(Revenue) AS [sum_Revenue(billions US$)]
FROM Portfolio..CanadianCompanies
GROUP BY Industry
ORDER BY [sum_Revenue(billions US$)] DESC
-- Rank all headquarter locations based on combined value
SELECT Headquarters, SUM(Value) AS [sum_Value(billions US$)]
FROM Portfolio..CanadianCompanies
GROUP BY Headquarters
ORDER BY [sum_Value(billions US$)] DESC