Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Funnel Path Query

HardSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is SQL Funnel Path Query. Start with the requirements and the two tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Uber's rider analytics team wants to understand how riders progress through the request funnel. Write a PostgreSQL query that identifies the most common observed path across five Uber ride steps during January 2025.

Requirements

  1. Join rider records to funnel events and keep only January 2025 events from the five defined funnel steps.
  2. Build one ordered path per rider using STRING_AGG, preserving repeated events and ordering ties by event_id.
  3. Return each distinct path, the number of riders following it, and its percentage of all riders with at least one valid funnel event.
  4. Sort by rider count descending, then path ascending.

Schema

riders
ColumnTypeDescription
rider_idPKINTEGERUnique rider identifier
rider_nameVARCHAR(100)Rider display name
cityVARCHAR(80)Rider's operating city
rider_funnel_events
ColumnTypeDescription
event_idPKINTEGERUnique funnel event identifier
rider_idINTEGERReferences riders.rider_id
event_nameVARCHAR(40)Observed funnel step
event_timeTIMESTAMPTimestamp when the event occurred
Tablesridersrider_funnel_events
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results