SQLQuokka
Start practicing
QuestionsLearnSandboxFeaturesRoadmapFAQ

Drivers With Back-to-Back Drops

Unsolved

Uber's supply team wants an early warning when a driver is disengaging. weekly_driver_trips has one row per driver per week, including weeks with 0 trips. A week counts as a drop when its completed_trips is at least 30% lower than the previous week's, which means this_week <= 0.7 × previous_week, and the previous week must be greater than 0 (a week after a 0 week can never be a drop). An alert fires in a week that is a drop and whose previous week was also a drop. Write an SQL query that returns driver_id, alert_week (the week_start of the second drop), trips_two_weeks_before, trips_week_before and trips_this_week for every alert. Order the results by driver_id, then alert_week.

SQL Query Editor (Ctrl+Enter to run)
0 characters · Valid
Canonical Solution Official

Official Solution is Hidden

Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.

Community Q&A & Discussion

Ask questions, share alternate queries, and explore solutions

0 comments
Asked By:
🏢 Uber

Submission History

Your recent query executions and answer checks

Execution Pipeline:
FROM weekly_driver_trips
Full source dataset
30 rows total
Ready. Type a query to see live execution.
Clause: Auto-Sync · AlaSQL Engine