diff options
author | emkael <emkael@tlen.pl> | 2015-03-31 10:26:28 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2015-03-31 10:26:28 +0200 |
commit | 7d157967431af94910e2dc0d8628ac09fd07519d (patch) | |
tree | a17486bd4ae89f8858270cbea19e8f1fd512c945 /views | |
parent | b6341f99578c1d6547139a3f855194685e94d7fc (diff) |
* view for average grid age
Diffstat (limited to 'views')
-rw-r--r-- | views/full_season_drivers.sql | 10 |
1 files changed, 10 insertions, 0 deletions
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; |