TASK #215 · Hard · CabifyDriver Utilization
Your brief
The driver_shifts table stores Cabify driver shifts: from
shift_start to shift_end the driver is online. Time on rides is the
interval from started_at to ended_at of completed rides
(status = 'completed'). Utilization is the total time on rides divided by
the total shift time, as a percentage.
Write a query that for every driver with at least one shift returns driver_name, online_hours (the total shift time in hours) and utilization_pct (the utilization); round both numbers to two decimals. A driver with shifts but no completed rides gets a utilization of 0. Sort by utilization_pct descending and, on ties, by driver_name alphabetically.
Write a query that for every driver with at least one shift returns driver_name, online_hours (the total shift time in hours) and utilization_pct (the utilization); round both numbers to two decimals. A driver with shifts but no completed rides gets a utilization of 0. Sort by utilization_pct descending and, on ties, by driver_name alphabetically.
Ctrl / ⌘ + ↵
Result
Write a query and run it to see the results.
Schema
driversdriver_id, driver_name, city, car_modeldriver_shiftsshift_id, driver_id, shift_start, shift_endridesride_id, driver_id, city, requested_at, status, started_at, ended_at, distance_km, surge_multiplier, fare_eur