-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic.sql
232 lines (206 loc) · 9.55 KB
/
basic.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
create view kill_data as (
select file,round,att_team,att_side,att_id,COUNT(*)
from(select distinct *
from(select file, round, tick,att_team,vic_team,att_side,vic_side,hp_dmg,arm_dmg,att_id,vic_id
from test_dmg
) as a1 natural join (select file,round,tick,att_team,vic_team,att_side,vic_side from test_kills) as a2
) as a3
group by file,round,att_team,att_side,att_id
)
;
--Kills per person per round per match--
select * from kill_data ;
-- --Kills per side per round per match--
-- select file,round,att_side,SUM(count) as count from kill_data group by file,round,att_side;
-- --Kills per team per round per match--
-- select file,round,att_team,SUM(count) as count from kill_data group by file,round,att_team;
-- --Kills per team per match--
-- select file,att_team,SUM(count) as count from kill_data group by file,att_team;
--Kills per person per match--
select file,att_team,att_side,att_id,SUM(count) as count from kill_data group by file,att_team,att_side,att_id;
-- --Kills per side per match--
-- select file,att_side,SUM(count) as count from kill_data group by file,att_side;
-- --Highest kills per person per round per match--
-- select file,round,att_team,att_side,att_id,count
-- from(select file,round,att_team,att_side,att_id,count,rank() OVER (PARTITION BY file,round ORDER BY file,round,count desc,att_id) as rank
-- from kill_data
-- ) as a4
-- where rank <=1
-- ;
--Highest kills per person per match--
with kill_data2 as (select file,att_team,att_side,att_id,SUM(count) as count from kill_data group by file,att_team,att_side,att_id)
select file,att_team,att_side,att_id,count
from(select file,att_team,att_side,att_id,count,rank() OVER (PARTITION BY file ORDER BY file,count desc,att_id) as rank
from kill_data2
) as a4
where rank <=1
;
--Lowest kills per person per round per match--
select file,round,att_team,att_side,att_id,count
from(select file,round,att_team,att_side,att_id,count,rank() OVER (PARTITION BY file,round ORDER BY file,round,count,att_id) as rank
from kill_data
) as a4
where rank <=1
;
-- --Lowest kills per person per match--
-- with kill_data2 as (select file,att_team,att_side,att_id,SUM(count) as count from kill_data group by file,att_team,att_side,att_id)
-- select file,att_team,att_side,att_id,count
-- from(select file,att_team,att_side,att_id,count,rank() OVER (PARTITION BY file ORDER BY file,count,att_id) as rank
-- from kill_data2
-- ) as a4
-- where rank <=1
-- ;
create view assist_data as (
select file,round,att_team,att_side,att_id,COUNT(*)
from(select file, round, tick,att_team,vic_team,att_side,vic_side,hp_dmg,arm_dmg,att_id,vic_id
from test_dmg
except
select *
from(select file, round, tick,att_team,vic_team,att_side,vic_side,hp_dmg,arm_dmg,att_id,vic_id
from test_dmg
) as a1 natural join (select file,round,tick,att_team,vic_team,att_side,vic_side from test_kills) as a2
) as a3
group by file,round,att_team,att_side,att_id
order by file,round,att_team,att_side,att_id
)
;
--Assists per person per round per match--
select * from assist_data;
--Assists per side per round per match--
select file,round,att_side,SUM(count) as count from assist_data group by file,round,att_side;
--Assists per team per round per match--
select file,round,att_team,SUM(count) as count from assist_data group by file,round,att_team;
--Assists per person per match--
select file,att_team,att_side,att_id,SUM(count) as count from assist_data group by file,att_team,att_side,att_id;
--Assists per team per match--
select file,att_team,SUM(count) as count from assist_data group by file,att_team;
--Assists per side per match--
select file,att_side,SUM(count) as count from assist_data group by file,att_side;
--Highest assists per person round per match--
select file,round,att_team,att_side,att_id,count
from(select file,round,att_team,att_side,att_id,count,rank() OVER (PARTITION BY file,round ORDER BY file,round,count desc,att_id) as rank
from assist_data
) as a4
where rank <=1
--Highest assists per person per match--
with assist_data2 as (select file,att_team,att_side,att_id,SUM(count) as count from assist_data group by file,att_team,att_side,att_id)
select file,att_team,att_side,att_id,count
from(select file,att_team,att_side,att_id,count,rank() OVER (PARTITION BY file ORDER BY file,count desc,att_id) as rank
from assist_data2
) as a4
where rank <=1
;
--Lowest assists per person round per match--
select file,round,att_team,att_side,att_id,count
from(select file,round,att_team,att_side,att_id,count,rank() OVER (PARTITION BY file,round ORDER BY file,round,count ,att_id) as rank
from assist_data
) as a4
where rank <=1
--Lowest assists per person per match--
with assist_data2 as (select file,att_team,att_side,att_id,SUM(count) as count from assist_data group by file,att_team,att_side,att_id)
select file,att_team,att_side,att_id,count
from(select file,att_team,att_side,att_id,count,rank() OVER (PARTITION BY file ORDER BY file,count ,att_id) as rank
from assist_data2
) as a4
where rank <=1
;
create view death_data as (
select file, round, vic_team, vic_side, vic_id, COUNT(*)
from(
select distinct *
from(select file, round, tick,att_team,vic_team,att_side,vic_side,hp_dmg,arm_dmg,att_id,vic_id
from test_dmg
) as a1 natural join (select file,round,tick,att_team,vic_team,att_side,vic_side from test_kills) as a2
) as a3
group by file, round, vic_team, vic_side, vic_id
)
;
--Deaths per person per round per match--
select * from death_data;
--Deaths per side per round per match--
select file,round,vic_side,SUM(count) as count from death_data group by file,round,vic_side;
--Deaths per team per round per match--
select file,round,vic_team,SUM(count) as count from death_data group by file,round,vic_team;
--Deaths per person per match--
select file,vic_team,vic_side,vic_id,SUM(count) as count from death_data group by file,vic_team,vic_side,vic_id;
--Deaths per team per match--
select file,vic_team,SUM(count) as count from death_data group by file,vic_team;
--Deaths per side per match--
select file,vic_side,SUM(count) as count from death_data group by file,vic_side;
--Highest deaths per person per round per match--
select file, vic_team, vic_side, vic_id,count
from(select file,vic_team, vic_side, vic_id,count,rank() OVER (PARTITION BY file ORDER BY file,count desc,vic_id) as rank
from death_data
) as a4
where rank <=1
;
--Highest deaths per person per match--
with death_data2 as (select file,vic_team,vic_side,vic_id,SUM(count) as count from death_data group by file,vic_team,vic_side,vic_id)
select file, vic_team, vic_side, vic_id,count
from(select file,vic_team, vic_side, vic_id,count,rank() OVER (PARTITION BY file ORDER BY file,count desc,vic_id) as rank
from death_data2
) as a4
where rank <=1
;
--Lowest deaths per person per round per match--
select file, vic_team, vic_side, vic_id,count
from(select file,vic_team, vic_side, vic_id,count,rank() OVER (PARTITION BY file ORDER BY file,count ,vic_id) as rank
from death_data
) as a4
where rank <=1
;
--Lowest deaths per person per match--
with death_data2 as (select file,vic_team,vic_side,vic_id,SUM(count) as count from death_data group by file,vic_team,vic_side,vic_id)
select file, vic_team, vic_side, vic_id,count
from(select file,vic_team, vic_side, vic_id,count,rank() OVER (PARTITION BY file ORDER BY file,count,vic_id) as rank
from death_data2
) as a4
where rank <=1
;
--Kill/Death ratio per person per match--
create view kdratio as (
with kill_data2 as (select file,att_team,att_side,att_id,SUM(count) as kills from kill_data group by file,att_team,att_side,att_id),
death_data2 as (select file,vic_team,vic_side,vic_id,SUM(count) as deaths from death_data group by file,vic_team,vic_side,vic_id)
select file,att_team,att_side,att_id,ROUND( cast(kills as decimal)/deaths,2) as ratio
from kill_data2 natural join death_data2
where att_team=vic_team and att_side =vic_side and att_id = vic_id
)
;
--Highest Kill/Death ratio per person per match--
select file,att_team,att_side,att_id,ratio
from(select file,att_team,att_side,att_id,ratio,rank() OVER (PARTITION BY file ORDER BY file,ratio desc,att_id) as rank
from kdratio
) as a4
where rank <=1
;
--Lowest Kill/Death ratio per person per match--
select file,att_team,att_side,att_id,ratio
from(select file,att_team,att_side,att_id,ratio,rank() OVER (PARTITION BY file ORDER BY file,ratio ,att_id) as rank
from kdratio
) as a4
where rank <=1
;
--MOST VALUABLE PLAYER per match--
create view mvp as (
with kill_data2 as (select file,att_team,att_side,att_id,SUM(count) as kills from kill_data group by file,att_team,att_side,att_id),
assist_data2 as (select file,att_team,att_side,att_id,SUM(count) as assists from assist_data group by file,att_team,att_side,att_id),
value_data as (select file,att_team,att_side,att_id,(kills+assists) as value from kill_data2 natural join assist_data2)
select file,att_team,att_side,att_id,value
from(select file,att_team,att_side,att_id,value,rank() OVER (PARTITION BY file ORDER BY file,value desc,att_id) as rank
from value_data
) as a4
where rank <=1
)
;
--PER PLAYER STATISTICS--
with kill_data2 as (select att_id,SUM(count) as kills from kill_data group by att_id),
assist_data2 as (select att_id,SUM(count) as assists from assist_data group by att_id),
death_data2 as (select vic_id as att_id,SUM(count) as deaths from death_data group by vic_id),
mvp2 as (select att_id,COUNT(*) as num_mvp from mvp group by att_id)
select att_id,kills,assists,deaths,ROUND( cast(kills as decimal)/deaths,2) as kd_ratio,num_mvp from kill_data2 natural join assist_data2 natural join death_data2 natural join mvp2
;
drop view mvp;
drop view kdratio;
drop view kill_data;
drop view death_data;
drop view assist_data;