From 7d157967431af94910e2dc0d8628ac09fd07519d Mon Sep 17 00:00:00 2001 From: emkael Date: Tue, 31 Mar 2015 10:26:28 +0200 Subject: * view for average grid age --- views/full_season_drivers.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/views/full_season_drivers.sql b/views/full_season_drivers.sql index 0ad0bbd..2ab10b9 100644 --- a/views/full_season_drivers.sql +++ b/views/full_season_drivers.sql @@ -32,3 +32,13 @@ CREATE VIEW full_season_drivers AS JOIN driver_season_races ON (season_races.races = driver_season_races.races) AND (season_races.year = driver_season_races.year); + +-- average grid age for every race +DROP VIEW IF EXISTS average_grid_age; +CREATE VIEW average_grid_age AS + SELECT AVG(DATEDIFF(races.date, drivers.dob)) average_age, + CONCAT(races.year, ' ', races.name) race, races.date + FROM driver_races + JOIN races ON driver_races.raceId = races.raceId + JOIN drivers ON drivers.driverId = driver_races.driverId + GROUP BY races.raceId; -- cgit v1.2.3