Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
SQL Cohort Performance Over Time
00:00
5 left

SQL Cohort Performance Over Time

HardSQL · PostgreSQL

Problem

How do you write a query to identify top-performing customer cohorts over a 6-month period?

Calculate cohort performance for customers who signed up from January through June 2024, using completed Bolt rides during the same period.

Output

  1. One row per signup-month cohort, including cohorts with no completed rides.
  2. Columns: cohort_month, cohort_customers, completed_rides, total_revenue, and performance_rank.
  3. Order by performance_rank ascending, then cohort_month ascending. Ties should share the same rank.

Schema

customers
ColumnTypeDescription
customer_idPKINTUnique customer identifier
customer_nameVARCHAR(100)Customer display name
signup_dateDATEDate the customer joined Bolt
emailVARCHAR(255)Customer email address
rides
ColumnTypeDescription
ride_idPKINTUnique ride identifier
customer_idINTCustomer who took the ride
ride_dateDATEDate of the ride
ride_statusVARCHAR(20)Ride completion status
fare_amountDECIMAL(10,2)Fare charged for the ride
Tablescustomersrides
Interviewer

Your question is SQL Cohort Performance Over Time. 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.