Changes between Version 15 and Version 16 of AdvancedDatabaseReports


Ignore:
Timestamp:
01/29/23 22:01:41 (22 months ago)
Author:
181085
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedDatabaseReports

    v15 v16  
    1313
    1414{{{#!sql:
    15 SELECT uuid_generate_v4() as id, pay.passenger_id, d.driver_id, SUM(d.km_travelled) as km_travelled_with_driver,
     15SELECT uuid_generate_v4() as id, pay.passenger_id, d.driver_id, dr.first_name as driver_name, dr.surname as driver_surname, SUM(d.km_travelled) as km_travelled_with_driver,
    1616SUM(pay.total_sum_payed) as total_price_paid, SUM(pay.total_sum_payed)/SUM(d.km_travelled) as price_per_km
    1717FROM request r
    1818JOIN drive d ON r.request_id = d.request_id
    1919JOIN payment pay ON d.drive_id = pay.drive_id
    20 GROUP BY d.driver_id, pay.passenger_id
     20left join driver dr on d.driver_id = dr.driver_id
     21GROUP BY d.driver_id, dr.first_name, dr.surname, pay.passenger_id
    2122ORDER BY price_per_km asc
    2223}}}
     
    2526
    2627{{{#!sql:
    27 SELECT uuid_generate_v4() as id, dr.driver_id, dr.email, dr.first_name as driver_name, dr.surname as driver_surname, c.make, c.model, (CASE WHEN num_grades > 2 THEN AVG(de.grade) ELSE NULL END) as driver_grade, COUNT(*) as number_of_drives,
     28SELECT uuid_generate_v4() as id, dr.driver_id, dr.email as driver_email, dr.first_name as driver_name, dr.surname as driver_surname, c.make, c.model, (CASE WHEN num_grades > 2 THEN AVG(de.grade) ELSE 0 END) as driver_grade, COUNT(*) as number_of_drives,
    2829SUM(p.total_sum_payed) as total_money_made, COUNT(DISTINCT de.request_id) as number_of_different_requests,
    2930COUNT(DISTINCT r.passenger_id) as number_of_different_passengers, (SUM(p.total_sum_payed))/COUNT(DISTINCT de.request_id) as average_money_per_request,
     
    3637LEFT JOIN request r ON de.request_id = r.request_id
    3738GROUP BY dr.driver_id, dr.email, dr.first_name, dr.surname, c.make, c.model
    38 ORDER BY driver_grade DESC
     39ORDER BY driver_grade desc
    3940}}}
    4041
     
    4243
    4344{{{#!sql:
    44 SELECT p.passenger_id, p.email, SUM(d.km_travelled) as km_travelled_with_passenger,
     45SELECT uuid_generate_v4() as id, d.driver_id, p.passenger_id, p.email as passenger_email, p.first_name as passenger_name, p.surname as passenger_surname, SUM(d.km_travelled) as km_travelled_with_passenger,
    4546SUM(pay.total_sum_payed) as total_earnings, SUM(pay.total_sum_payed)/SUM(d.km_travelled) as earnings_per_km,
    4647AVG(d.grade) as average_grade_received_per_drive, COUNT(*) as number_of_drives
     
    4950JOIN drive d ON r.request_id = d.request_id
    5051JOIN payment pay ON d.drive_id = pay.drive_id
    51 WHERE d.driver_id = '7c183cbe-bfb3-4e16-b831-e4f73c4f4937'
    52 GROUP BY p.passenger_id , p.email
     52GROUP BY p.passenger_id , p.email, p.first_name,  p.surname, d.driver_id
    5353ORDER BY earnings_per_km DESC
    5454}}}