-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shark Tank India Data Analysis ORCLPDB1.sql
179 lines (111 loc) · 4 KB
/
Shark Tank India Data Analysis ORCLPDB1.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
select * from projectdata;
-- total episodes
SELECT MAX(ep) FROM projectdata;
SELECT COUNT(DISTINCT ep) FROM projectdata;
-- pitches
SELECT COUNT(DISTINCT brand) FROM projectdata;
--pitches converted
SELECT AVG(a.EQUITY_TAKEN_)
FROM
(SELECT *
FROM projectdata
WHERE EQUITY_TAKEN_ > 0) a;
-- total male
SELECT SUM(male) FROM projectdata;
-- total female
SELECT SUM(female) FROM projectdata;
--gender ratio
SELECT SUM(female) / SUM(male) AS gender_ratio
FROM projectdata;
-- total invested amount
SELECT SUM(AMOUNT_INVESTED_LAKHS) AS total_invested_amount
FROM projectdata;
-- avg equity taken
SELECT AVG(a.EQUITY_ASKED_)
FROM
(SELECT *
FROM projectdata
WHERE EQUITY_ASKED_ > 0) a;
--highest deal taken
SELECT MAX(AMOUNT_INVESTED_LAKHS) FROM projectdata;
--higheest equity taken
SELECT MAX(EQUITY_TAKEN_)
FROM projectdata;
-- startups having at least women
SELECT SUM(a.female_count) AS startups_having_at_least_women
FROM (
SELECT CASE WHEN female > 0 THEN 1 ELSE 0 END AS female_count
FROM projectdata -- Replace 'projectdata' with the correct table name
) a;
-- pitches converted having atleast ne women
SELECT *
FROM projectdata;
SELECT SUM(b.female_count)
FROM
(SELECT CASE WHEN a.female > 0 THEN 1 ELSE 0 END AS female_count, a.*
FROM
(SELECT *
FROM projectdata
WHERE deal != 'No Deal') a) b;
-- avg team members
SELECT AVG(team_members) FROM projectdata;
-- amount invested per deal
SELECT AVG(a.AMOUNT_INVESTED_LAKHS) AS amount_invested_per_deal
FROM (SELECT *
FROM projectdata
WHERE deal != 'No Deal') a;
-- avg age group of contestants
SELECT AVG_AGE, COUNT(AVG_AGE) AS cnt
FROM projectdata
GROUP BY AVG_AGE
ORDER BY cnt DESC;
-- location group of contestants
SELECT location, COUNT(location) AS cnt
FROM projectdata
GROUP BY location
ORDER BY cnt DESC;
-- sector group of contestants
SELECT sector, COUNT(sector) AS cnt
FROM projectdata
GROUP BY sector
ORDER BY cnt DESC;
--partner deals
SELECT partners, COUNT(partners) AS cnt
FROM projectdata
WHERE partners != '-'
GROUP BY partners
ORDER BY cnt DESC;
-- making the matrix
SELECT *
FROM projectdata;
SELECT 'Ashnner' AS keyy, COUNT(ASHNEER_AMOUNT_INVESTED)
FROM projectdata
WHERE ASHNEER_AMOUNT_INVESTED IS NOT NULL;
SELECT 'Ashnner' AS keyy, COUNT(CAST(ASHNEER_AMOUNT_INVESTED AS NUMBER))
FROM projectdata
WHERE ASHNEER_AMOUNT_INVESTED IS NOT NULL AND ASHNEER_AMOUNT_INVESTED != 0;
SELECT 'Ashneer' AS keyy, SUM(C.ASHNEER_AMOUNT_INVESTED), AVG(C.ASHNEER_EQUITY_TAKEN_)
FROM (SELECT *
FROM projectdata
WHERE ASHNEER_EQUITY_TAKEN_ != 0 AND ASHNEER_EQUITY_TAKEN_ IS NOT NULL) C;
SELECT m.keyy, m.total_deals_present, m.total_deals, n.total_amount_invested, n.avg_equity_taken
FROM (SELECT a.keyy, a.total_deals_present, b.total_deals
FROM (SELECT 'Ashneer' AS keyy, COUNT(ASHNEER_AMOUNT_INVESTED) AS total_deals_present
FROM projectdata
WHERE ASHNEER_AMOUNT_INVESTED IS NOT NULL) a
INNER JOIN (SELECT 'Ashneer' AS keyy, COUNT(ASHNEER_AMOUNT_INVESTED) AS total_deals
FROM projectdata
WHERE ASHNEER_AMOUNT_INVESTED IS NOT NULL AND ASHNEER_AMOUNT_INVESTED != 0) b
ON a.keyy = b.keyy) m
INNER JOIN (SELECT 'Ashneer' AS keyy, SUM(C.ASHNEER_AMOUNT_INVESTED) AS total_amount_invested, AVG(C.ASHNEER_EQUITY_TAKEN_) AS avg_equity_taken
FROM (SELECT *
FROM projectdata
WHERE ASHNEER_EQUITY_TAKEN_ != 0 AND ASHNEER_EQUITY_TAKEN_ IS NOT NULL) C) n
ON m.keyy = n.keyy;
-- which is the startup in which the highest amount has been invested in each domain/sector
SELECT brand, sector, AMOUNT_INVESTED_LAKHS
FROM (
SELECT brand, sector, AMOUNT_INVESTED_LAKHS, RANK() OVER (PARTITION BY sector ORDER BY AMOUNT_INVESTED_LAKHS DESC) AS rnk
FROM projectdata
) c
WHERE c.rnk = 1;