Query carpool ride metrics
Company: Meta
Role: Data Engineer
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Onsite
Overview: This question evaluates proficiency in data manipulation and analytical querying using SQL and Python to compute ride-sharing metrics such as daily completed pooled rides, average seats utilized, and cancellation rate.
Tables
users(user_id INTEGER, name VARCHAR(100), signup_date DATE)
drivers(driver_id INTEGER, user_id INTEGER)
pooled_rides(pool_id INTEGER, driver_id INTEGER, start_time TIMESTAMP, end_time TIMESTAMP, status VARCHAR(20), seat_capacity INTEGER)
pool_bookings(booking_id INTEGER, pool_id INTEGER, rider_id INTEGER, seats_booked INTEGER, status VARCHAR(30), created_at TIMESTAMP, cancel_time TIMESTAMP)
Hints
- Treat each pooled ride (vehicle journey) as one unit and sum completed seat bookings per pool to get seats utilized.
- Use conditional aggregation on pool_bookings.created_at to compute cancellations and total bookings per day.
Community answers
Answer by ginb
Answer by ginb