Deduplicating Retried Trip Events Before Joining to Payments

Last updated: November 29, 2026

Quick Overview

Trip status events are duplicated by client retries and payments can have several attempts per trip. Write a query that computes completed trips and captured revenue per city without double counting.

Uber
Data Manipulation (SQL/Python)
Data Engineer
Uber
November 29, 2026
Data Engineer
Technical Screen
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


Trip status events are duplicated by client retries and payments can have several attempts per trip. Write a query that computes completed trips and captured revenue per city without double counting.

Uber's event pipelines deliver at least once, so duplicated rows and many-to-many joins are a constant source of inflated revenue numbers. The interviewer checks that you dedupe each side to the right grain before joining.

What the Interviewer Expects
  • Identify the grain of each table and the join key
  • Pick the latest state per trip with ROW_NUMBER
  • Keep one captured payment per trip and flag duplicates
  • Use a LEFT JOIN to find completed trips without capture
  • Explain why joining before deduplication inflates sums
Key Topics to Cover
deduplication
ROW_NUMBER
join fan-out
data quality
late-arriving data
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you detect riders who were charged twice?
  • What if a late event changes a trip from completed to cancelled after the report ran?
  • How would you make this incremental in a daily pipeline?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

trip_events(trip_id, city_id, status, event_ts, ingested_at): many rows per trip (state changes plus retried duplicates). payments(payment_id, trip_id, amount_usd, payment_status, created_at): fai...

Approach
  1. Reduce trip_events to the latest state per trip, ordering by event_ts then ingested_at to break ties between duplicates.
  2. Reduce payments to the first captured payment per trip.
  3. Left joi...

Submit Your Answer
Markdown supported