Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Compare Rider Retention by Signup Cohort
00:00
5 left

Compare Rider Retention by Signup Cohort

HardSQL · PostgreSQL

Problem

Write a PostgreSQL query to compare month-1 retention across monthly rider signup cohorts. A rider belongs to the cohort of their signup_date month, and is considered retained if they complete at least one ride in the next calendar month. Return cohort month, cohort size, retained riders, and retention rate.

Schema

riders
ColumnTypeDescription
rider_id
rider_name
signup_date
city
rides
ColumnTypeDescription
ride_id
rider_id
ride_date
status
fare_amount

What to watch for

  • Use only rides with status = 'completed'.
  • Riders with no rides must still count toward cohort size.
  • Multiple completed rides in the same retention month should count once.
  • Order results by cohort month.
Tablesridersrides
Interviewer

Your question is Compare Rider Retention by Signup Cohort. Start with the requirements and the two tables in the Question tab.

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.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.