Changes between Version 5 and Version 6 of AdvancedDatabaseReports
- Timestamp:
- 12/20/22 12:33:51 (2 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AdvancedDatabaseReports
v5 v6 9 9 {{{#!sql: 10 10 SELECT d.driver_id, SUM(d.km_travelled) as km_travelled_with_driver, 11 SUM(pay.total_sum_payed) as total_price_paid 11 SUM(pay.total_sum_payed) as total_price_paid, SUM(d.km_travelled)/SUM(pay.total_sum_payed) as price_per_km 12 12 FROM request r 13 13 JOIN drive d ON r.request_id = d.request_id … … 15 15 WHERE r.passenger_id = '77d9c766-e0c1-4e53-86d0-bafc3101a1ac' AND 16 16 d.start_time between now() and now() - interval '2 months' 17 GROUP BY d.driver_id 17 GROUP BY d.driver_id 18 ORDER BY price_per_km ASC 18 19 }}} 20 21 {{{#!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, 23 SUM(p.total_sum_payed) as total_money_made, COUNT(DISTINCT de.request_id) as number_of_different_requests, 24 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, 25 SUM(d.km_travelled) as total_km_travelled 26 FROM 27 driver dr 28 JOIN drive de ON dr.driver_id = de.driver_id 29 JOIN payment p ON de.drive_id = p.drive_id 30 LEFT JOIN request r ON de.request_id = r.request_id 31 GROUP BY dr.driver_id, dr.email 32 ORDER BY driver_grade DESC 33 }}