-
Notifications
You must be signed in to change notification settings - Fork 0
/
nebraska_analysis_sql.sql
287 lines (235 loc) · 8.49 KB
/
nebraska_analysis_sql.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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
-- Preview the tables
SELECT *
FROM all_defense;
SELECT *
FROM all_offense;
SELECT *
FROM nebraska_defense;
SELECT *
FROM nebraska_offense;
SELECT *
FROM standings;
-- Basic Counts
SELECT COUNT(date) AS games_played
FROM nebraska_offense; -- 287
SELECT COUNT( DISTINCT opponent)
FROM nebraska_offense; -- 79
SELECT COUNT (outcome)
FROM nebraska_offense
WHERE outcome = "W"; --168
SELECT COUNT (outcome)
FROM nebraska_offense
WHERE outcome = "L"; --119
SELECT Min (date), opponent, score
FROM nebraska_offense; -- 2000-09-02 00:00:00 San Jose State W (49-13)
SELECT Max (date), opponent, score
FROM nebraska_offense; -- 2022-11-25 00:00:00 Iowa W (24-17)
-----------------------------------
-- Analyis - Nebraska Offense
-----------------------------------
-- Top Performances (Rushing)
SELECT date, opponent, score, rushing_yds, rushing_avg, rushing_td, points_for - points_against AS point_diff
FROM nebraska_offense
ORDER BY rushing_yds DESC
LIMIT 10;
-- Top Performances (Passing)
SELECT date, opponent, score, passing_cmp, passing_att, passing_pct, passing_yds, passing_td, points_for - points_against AS point_diff
FROM nebraska_offense
ORDER BY passing_yds DESC
LIMIT 10;
-- Top Rushing Performances Evaluating Nebraska's Defense
SELECT no.date, no.opponent, no.score, no.rushing_yds, nd.total_yds AS opponent_total_yards, no.points_for - no.points_against AS point_diff
FROM nebraska_offense AS no
INNER JOIN nebraska_defense AS nd on no.date = nd.date
ORDER BY no.rushing_yds DESC
LIMIT 10;
-- Top Passing Performances Evaluating Nebraska's Defense
SELECT no.date, no.opponent, no.score, no.passing_yds, nd.total_yds AS opponent_total_yards, no.points_for - no.points_against AS point_diff
FROM nebraska_offense AS no
INNER JOIN nebraska_defense AS nd on no.date = nd.date
ORDER BY no.passing_yds DESC
LIMIT 10;
-- Top Scoring Performances
SELECT date, opponent, points_for, points_against
FROM nebraska_offense
ORDER BY points_for DESC
LIMIT 10;
-- How has the offense changed
SELECT strftime('%Y', date) AS year, ROUND(AVG(points_for), 2) AS avg_points
FROM nebraska_offense
GROUP BY strftime('%Y', date)
ORDER BY avg_points DESC;
-----------------------------------
-- Analyis - Nebraska Defense
-----------------------------------
-- Top Performances (Rushing Defense)
SELECT date, opponent, score, rushing_yds, rushing_avg, rushing_td, points_for - points_against AS point_diff
FROM nebraska_defense
ORDER BY rushing_yds ASC
LIMIT 10;
-- Top Performances (Passing Defense)
SELECT date, opponent, score, passing_cmp, passing_att, passing_pct, passing_yds, passing_td, points_for - points_against AS point_diff
FROM nebraska_defense
ORDER BY passing_yds ASC
LIMIT 10;
-- Top Rushing Defense Performances Evaluating Nebraska's Offense
SELECT nd.date, nd.opponent, nd.score, nd.rushing_yds, no.total_yds AS Nebraska_total_yards, (nd.points_for - nd.points_against) AS point_diff
FROM nebraska_defense nd
INNER JOIN nebraska_offense no ON nd.date = no.date
ORDER BY nd.rushing_yds ASC
LIMIT 10;
-- Top Passing Defense Performances Evaluating Nebraska's Offense
SELECT nd.date, nd.opponent, nd.score, nd.passing_yds, no.total_yds AS Nebraska_total_yards, (nd.points_for - nd.points_against) AS point_diff
FROM nebraska_defense nd
INNER JOIN nebraska_offense no ON nd.date = no.date
ORDER BY nd.passing_yds ASC
LIMIT 10;
-- Top Defensive Performances based on Score
SELECT date, opponent, points_for, points_against
FROM nebraska_defense
ORDER BY points_against ASC
LIMIT 10;
-- How has the Defense changed
SELECT strftime('%Y', date) AS year, ROUND(AVG(points_against), 2) AS avg_points_against
FROM nebraska_defense
GROUP BY strftime('%Y', date)
ORDER BY avg_points_against ASC;
-----------------------------------------------
-- Analyis - Nebraska Penalties and Turnovers
-----------------------------------------------
-- What was the outcome of the 10 worst performances based on turnovers
SELECT date, opponent, score, fumbles, intceptions, turnovers
FROM nebraska_offense
ORDER BY turnovers DESC
LIMIT 10;
-- What the hell happened with that Iowa State game in 2009?
SELECT *
FROM nebraska_offense
WHERE date = "2009-10-24 00:00:00";
SELECT *
FROM nebraska_defense
WHERE date = "2009-10-24 00:00:00";
-- Link this to the Paul Rhodes Clip
SELECT opponent, passing_cmp, passing_att, passing_yds, passing_td, rushing_att, rushing_yds, rushing_avg, rushing_td, total_yds
FROM nebraska_defense
WHERE date = "2009-10-24 00:00:00";
-- Does ISU have Nebraska's Number?
SELECT *
FROM standings
WHERE year = "2009" AND (school = "Nebraska" OR school = "Iowa State");
-- What was the outcome of the 10 best performances based on turnovers
SELECT date, opponent, score, fumbles, intceptions, turnovers
FROM nebraska_defense
ORDER BY turnovers DESC
LIMIT 10;
-- What the hell happened with that Oklahoma game in 2009?
SELECT *
FROM nebraska_offense
WHERE date = "2009-11-07 00:00:00";
SELECT *
FROM nebraska_defense
WHERE date = "2009-11-07 00:00:00";
-- How did these teams finish the season?
SELECT *
FROM standings
WHERE year = "2009" AND (school = "Nebraska" OR school = "Oklahoma");
-- What was the outcome of the 10 worst performances based on penalties
SELECT no.date, no.opponent, no.score, no.penalties, no.penalty_yds, nd.penalties, nd.penalty_yds, (no.penalties + nd.penalties) AS total_penalties, (no.penalty_yds + nd.penalty_yds) AS total_penalty_yds
FROM nebraska_offense AS no
INNER JOIN nebraska_defense AS nd ON nd.date = no.date
ORDER BY total_penalty_yds DESC
LIMIT 10;
-----------------------------------------------
-- Analyis - Standings
-----------------------------------------------
-- What is the range for SRS
SELECT year, school, wins, losses, MAX(SRS)
FROM standings; -- 30.26
SELECT year, school, wins, losses, MIN(SRS)
FROM standings; -- (-29.95)
-- What years were we doing well?
SELECT *
FROM standings
WHERE school = "Nebraska"
ORDER BY SRS DESC;
-- What years were we doing poorly?
SELECT *
FROM standings
WHERE school = "Nebraska"
ORDER BY SRS ASC;
-----------------------------------------------
-- Analyis - All Offense
-----------------------------------------------
-- Top Performances (Rushing Yards)
SELECT year, school, rushing_yds, rushing_td
FROM all_offense
ORDER BY rushing_yds DESC
LIMIT 10;
-- Top Performances (Rushing TDs)
SELECT year, school, rushing_yds, rushing_td
FROM all_offense
ORDER BY rushing_td DESC
LIMIT 10;
-- Top Performances (Passing Yards)
SELECT year, school, passing_cmp, passing_att, passing_pct, passing_yds, passing_td
FROM all_offense
ORDER BY passing_yds DESC
LIMIT 10;
-- Top Performances (Passing TDs)
SELECT year, school, passing_cmp, passing_att, passing_pct, passing_yds, passing_td
FROM all_offense
ORDER BY passing_td DESC
LIMIT 10;
-- Top Performances (Passing Efficiency)
SELECT year, school, passing_cmp, passing_att, passing_pct, passing_yds, passing_td
FROM all_offense
ORDER BY passing_pct DESC
LIMIT 10;
-- Top Performances (Total TDs)
SELECT year, school, rushing_td, passing_td, (rushing_td + passing_td) AS total_td
FROM all_offense
ORDER BY total_td DESC
LIMIT 10;
-- Top Performances (Total Yards)
SELECT year, school, total_yds
FROM all_offense
ORDER BY total_yds DESC
LIMIT 10;
-----------------------------------------------
-- Analyis - All defense
-----------------------------------------------
-- Top Performances (Rushing Yards)
SELECT year, school, rushing_yds, rushing_td
FROM all_defense
ORDER BY rushing_yds ASC
LIMIT 10;
-- Top Performances (Rushing TDs)
SELECT year, school, rushing_yds, rushing_td
FROM all_defense
ORDER BY rushing_td ASC
LIMIT 10;
-- Top Performances (Passing Yards)
SELECT year, school, passing_cmp, passing_att, passing_pct, passing_yds, passing_td
FROM all_defense
ORDER BY passing_yds ASC
LIMIT 10;
-- Top Performances (Passing TDs)
SELECT year, school, passing_cmp, passing_att, passing_pct, passing_yds, passing_td
FROM all_defense
ORDER BY passing_td ASC
LIMIT 10;
-- Top Performances (Passing Efficiency)
SELECT year, school, passing_cmp, passing_att, passing_pct, passing_yds, passing_td
FROM all_defense
ORDER BY passing_pct ASC
LIMIT 10;
-- Top Performances (Total TDs)
SELECT year, school, rushing_td, passing_td, (rushing_td + passing_td) AS total_td
FROM all_defense
ORDER BY total_td ASC
LIMIT 10;
-- Top Performances (Total Yards)
SELECT year, school, total_yds
FROM all_defense
ORDER BY total_yds ASC
LIMIT 10;