Ride-Share: ETA Accuracy

10pts
Uber, Lyft, Grab

Problem Statement

Uber’s marketplace health depends on accurate ETAs. If a driver is consistently arriving much later (or earlier) than predicted, it may indicate a technical issue with their GPS or a behavioral pattern.

Write a query to find "Inaccurate Drivers." A driver is considered inaccurate if:

  1. They have completed at least 3 total trips in the dataset.
  2. For at least 80% of their total trips, the absolute difference between predicted_arrival_time and actual_arrival_time is greater than 5 minutes.

Rules:

  • Absolute difference means if a driver is 6 minutes late OR 6 minutes early, both count as "off-schedule."
  • Use the timestamp difference to determine the minutes.
  • Output columns: driver_id, off_schedule_percentage, avg_deviation_minutes.
  • Sort by off_schedule_percentage descending, then avg_deviation_minutes descending.
Tests your understanding of
Window Functions, Date Arithmetic, Filtering and Aggregation

Input Tables

trips
trip_id(INTEGER)driver_id(INTEGER)predicted_arrival_time(TIMESTAMP)actual_arrival_time(TIMESTAMP)
11012026-03-04 10:00:002026-03-04 10:07:00
21012026-03-04 11:00:002026-03-04 11:06:00
31012026-03-04 12:00:002026-03-04 12:08:00
41022026-03-04 10:00:002026-03-04 10:01:00
51022026-03-04 11:00:002026-03-04 11:02:00
61022026-03-04 12:00:002026-03-04 12:01:00
71032026-03-04 14:00:002026-03-04 14:10:00
81032026-03-04 15:00:002026-03-04 15:15:00
91032026-03-04 16:00:002026-03-04 16:02:00

Expected Output

driver_id(INTEGER)off_schedule_percentage(DECIMAL)avg_deviation_minutes(DECIMAL)
1011007

Tags

HardWindow FunctionsDate ArithmeticFilteringAggregation
30-40 min
34%

Hints