-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueries.sql
executable file
·117 lines (105 loc) · 2.85 KB
/
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
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
SELECT rpt.teamnum, r.value as results FROM scouting.record r
join scouting.item i on i.ID = r.ITEM_ID and i.Name = 'rate shooting'
join scouting.report rpt on rpt.id = r.report_id and rpt.teamnum > 0
order by rpt.teamnum asc;
-----------
SELECT rpt.teamnum, i.Name, 2-avg(r.value) as rating FROM scouting.record r
join scouting.item i on i.ID = r.ITEM_ID and
i.Name in(
'Attempt Cheval De Frise',
'Attempt portcullis',
'Attempt Rock Wall',
'Attempt Sally Port',
'Attempt Low Bar',
'Attempt Rough Terrain',
'Attempt Ramparts',
'Attempt Drawbridge',
'Attempt Moat'
)
join scouting.report rpt on rpt.id = r.report_id and rpt.teamnum > 0 AND r.value < 3
group by rpt.teamnum, i.Name
order by rpt.teamnum asc, i.Name ASC;
------------
SELECT rpt.teamnum, i.Name, 2-AVG(r.value) AS rating
FROM scouting.record r
JOIN scouting.item i ON i.ID = r.ITEM_ID AND
i.Name IN(
'Attempt Cheval De Frise',
'Attempt portcullis',
'Attempt Rock Wall',
'Attempt Sally Port',
'Attempt Low Bar',
'Attempt Rough Terrain',
'Attempt Ramparts',
'Attempt Drawbridge',
'Attempt Moat'
)
JOIN scouting.report rpt ON rpt.id = r.report_id AND rpt.teamnum > 0 AND r.value < 3
GROUP BY rpt.teamnum, i.Name
UNION
SELECT rpt.teamNum, i.name, AVG(r.Value) AS rating
FROM scouting.record r
JOIN scouting.item i ON i.ID = r.ITEM_ID AND
i.Name IN(
'Auto: reaches over walls?',
'Auto: crosses outer works?',
'Auto: shooting?',
'Can shoot?',
'Can climb?',
'Rate shooting',
'Rate driving',
'Shoots High?',
'Shoots Low?'
)
JOIN scouting.report rpt ON rpt.id = r.report_id
GROUP BY rpt.teamnum, i.Name
UNION
SELECT rpt.teamNum, i.name, AVG(r.Value)/10 AS rating
FROM scouting.record r
JOIN scouting.item i ON i.ID = r.ITEM_ID AND
i.Name IN(
'Times Crossed Cheval De Frise',
'Times Crossed portcullis',
'Times Crossed Rock Wall',
'Times Crossed Sally Port',
'Times Crossed Low Bar',
'Times Crossed Rough Terrain',
'Times Crossed Ramparts',
'Times Crossed Drawbridge',
'Times Crossed Moat'
)
AND r.Value > 0
JOIN scouting.report rpt ON rpt.id = r.report_id
GROUP BY rpt.teamnum, i.Name
UNION
SELECT rpt.teamNum, i.name, -AVG(r.Value) AS rating
FROM scouting.record r
JOIN scouting.item i ON i.ID = r.ITEM_ID AND
i.Name IN(
'Got Stuck Cheval De Frise',
'Got Stuck portcullis',
'Got Stuck Rock Wall',
'Got Stuck Sally Port',
'Got Stuck Low Bar',
'Got Stuck Rough Terrain',
'Got Stuck Ramparts',
'Got Stuck Drawbridge',
'Got Stuck Moat'
)
AND r.Value > 0
JOIN scouting.report rpt ON rpt.id = r.report_id
GROUP BY rpt.teamnum, i.Name
ORDER BY teamnum ASC, Name ASC;
------------
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `procGetAverage`(
IN itemName VARCHAR(50)
)
BEGIN
SELECT rpt.teamnum, avg(r.value) as results FROM scouting.record r
join scouting.item i on i.ID = r.ITEM_ID and i.Name = itemName
join scouting.report rpt on rpt.id = r.report_id and rpt.teamnum > 0
group by rpt.teamnum
order by rpt.teamnum asc;
END$$
DELIMITER ;