aboutsummaryrefslogtreecommitdiff
path: root/dbinit/views.sql
diff options
context:
space:
mode:
Diffstat (limited to 'dbinit/views.sql')
-rw-r--r--dbinit/views.sql18
1 files changed, 18 insertions, 0 deletions
diff --git a/dbinit/views.sql b/dbinit/views.sql
index 5cdee0f..1e062a0 100644
--- a/dbinit/views.sql
+++ b/dbinit/views.sql
@@ -25,3 +25,21 @@ from
join `teams` on `calendar`.`ID` = `teams`.`calendarID`
join `teamsmember` on `teams`.`ID` = `teamsmember`.`teamsID`
join `member` on `teamsmember`.`memberID` = `member`.`ID`;
+
+create view `formula1`.`vwFastestLapRaceID` as
+select raceresult.raceID, min(raceresult.fastestlap) as fastestlap
+ from raceresult join
+ endposition on endposition.ID = raceresult.endPositionID
+ group by raceresult.raceID;
+
+create view `formula1`.`vwFastestlapMemberID` as
+select
+ vwFastestLapRaceID.raceID,
+ vwFastestLapRaceID.fastestlap,
+ endposition.memberID
+from vwFastestLapRaceID
+join raceresult on raceresult.raceID = vwFastestLapRaceID.raceID and raceresult.fastestlap = vwFastestLapRaceID.fastestlap
+join endposition on endposition.ID = raceresult.endPositionID
+group by raceresult.raceID;
+
+