Changes between Version 15 and Version 16 of AdvancedDatabaseReports
- Timestamp:
- 01/29/23 22:01:41 (22 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AdvancedDatabaseReports
v15 v16 13 13 14 14 {{{#!sql: 15 SELECT uuid_generate_v4() as id, pay.passenger_id, d.driver_id, SUM(d.km_travelled) as km_travelled_with_driver,15 SELECT 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, 16 16 SUM(pay.total_sum_payed) as total_price_paid, SUM(pay.total_sum_payed)/SUM(d.km_travelled) as price_per_km 17 17 FROM request r 18 18 JOIN drive d ON r.request_id = d.request_id 19 19 JOIN payment pay ON d.drive_id = pay.drive_id 20 GROUP BY d.driver_id, pay.passenger_id 20 left join driver dr on d.driver_id = dr.driver_id 21 GROUP BY d.driver_id, dr.first_name, dr.surname, pay.passenger_id 21 22 ORDER BY price_per_km asc 22 23 }}} … … 25 26 26 27 {{{#!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 NULLEND) as driver_grade, COUNT(*) as number_of_drives,28 SELECT 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, 28 29 SUM(p.total_sum_payed) as total_money_made, COUNT(DISTINCT de.request_id) as number_of_different_requests, 29 30 COUNT(DISTINCT r.passenger_id) as number_of_different_passengers, (SUM(p.total_sum_payed))/COUNT(DISTINCT de.request_id) as average_money_per_request, … … 36 37 LEFT JOIN request r ON de.request_id = r.request_id 37 38 GROUP BY dr.driver_id, dr.email, dr.first_name, dr.surname, c.make, c.model 38 ORDER BY driver_grade DESC39 ORDER BY driver_grade desc 39 40 }}} 40 41 … … 42 43 43 44 {{{#!sql: 44 SELECT p.passenger_id, p.email, SUM(d.km_travelled) as km_travelled_with_passenger,45 SELECT 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, 45 46 SUM(pay.total_sum_payed) as total_earnings, SUM(pay.total_sum_payed)/SUM(d.km_travelled) as earnings_per_km, 46 47 AVG(d.grade) as average_grade_received_per_drive, COUNT(*) as number_of_drives … … 49 50 JOIN drive d ON r.request_id = d.request_id 50 51 JOIN 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 52 GROUP BY p.passenger_id , p.email, p.first_name, p.surname, d.driver_id 53 53 ORDER BY earnings_per_km DESC 54 54 }}}