Skip to content

Biggest drop-off step in the ride funnel

MediumFull bankFunnelsRanking and top NConditional aggregation18 min2 hidden datasets

The task

Operations wants to know where each city loses the most ride requests. A trip moves through four steps:

  1. requested: every row of trips
  2. accepted: driver_id is not NULL
  3. picked_up: picked_up_at is not NULL
  4. completed: status is 'completed'

Every trip that reaches a step also reached the steps before it. The loss at a transition is the number of trips at the earlier step minus the number at the later step. The three transitions are named requested_to_accepted, accepted_to_picked_up and picked_up_to_completed.

For each city with at least one trip, find the transition with the largest loss. If two transitions tie (including when no trips are lost at all), pick the one that comes first in the funnel. Return:

  • city_name
  • drop_step: the name of that transition
  • trips_lost: the loss at that transition
  • pct_lost: trips_lost as a percentage of the trips at the earlier step of that transition, rounded to 1 decimal place

Sort by city_name.

Expected output

city_namedrop_steptrips_lostpct_lost
  • Sorted by city_name ascending.
  • Numbers rounded to 1 decimal place.
  • Checked on the sample and on 2 hidden datasets. How grading works

Tables Ride-hailing marketplace · click a name to insert it

cities4 rows in the sample

Cities we operate in. Key: city_id.

intUnique id.
textName.
textTwo-letter country code.
drivers60 rows in the sample

One row per driver. Key: driver_id.

intUnique id.
textName.
intHome city.
dateFirst day driving.
textstandard, xl or electric.
riders220 rows in the sample

One row per rider. Key: rider_id.

intUnique id.
textName.
dateSign-up day.
trips1,800 rows in the sample

One row per ride request. Key: trip_id.

intUnique id.
intWho asked.
intDriver who accepted. NULL when nobody did.
intWhere.
timestampRequest time (UTC).
timestampPickup time. NULL if never picked up.
timestampDrop-off time. NULL unless completed.
textcompleted, rider_cancelled, driver_cancelled or no_driver.
numeric(10,2)Fare in local currency units. NULL unless completed.
numeric(6,2)Trip distance. NULL unless completed.
intRider's rating of the driver, 1 to 5. NULL if not rated.

Related questions

Loading the editor and PostgreSQL