Changes between Version 7 and Version 8 of AdvancedDatabaseReports


Ignore:
Timestamp:
12/20/22 12:38:27 (2 years ago)
Author:
181085
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedDatabaseReports

    v7 v8  
    2020
    2121{{{#!sql:
    22 SELECT dr.driver_id, dr.email, (CASE WHEN num_grades > 2 THEN AVG(de.grade) ELSE NULL END) as driver_grade, COUNT(*) as number_of_drives,
     22SELECT dr.driver_id, dr.email, c.make, c.model, (CASE WHEN num_grades > 2 THEN AVG(de.grade) ELSE NULL END) as driver_grade, COUNT(*) as number_of_drives,
    2323SUM(p.total_sum_payed) as total_money_made, COUNT(DISTINCT de.request_id) as number_of_different_requests,
    2424COUNT(DISTINCT r.passenger_id) as number_of_different_passengers, (SUM(p.total_sum_payed))/COUNT(DISTINCT de.request_id) as average_money_per_request,
    25 SUM(d.km_travelled) as total_km_travelled
     25SUM(de.km_travelled) as total_km_travelled
    2626FROM
    2727driver dr
     28LEFT JOIN car c ON dr.driver_id = c.driver_id
    2829JOIN drive de ON dr.driver_id = de.driver_id
    2930JOIN payment p ON de.drive_id = p.drive_id
    3031LEFT JOIN request r ON de.request_id = r.request_id
    31 GROUP BY dr.driver_id, dr.email 
     32GROUP BY dr.driver_id, dr.email, c.make, c.model
    3233ORDER BY driver_grade DESC
    3334}}}