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
City Ride Demand SQL Analysis
00:00
5 left

City Ride Demand SQL Analysis

MediumSQL · PostgreSQL

Problem

Write a SQL query to analyze city-level ride demand, driver supply, and conversion trends over time for Didi Chuxing.

Use the cities, ride_requests, and driver_sessions tables. Report monthly metrics for the available reporting period, excluding requests without a valid city.

Output

  1. One row per city and month with ride requests, completed rides, active drivers, and conversion rate.
  2. Columns: city_name, month, ride_requests, completed_rides, active_drivers, conversion_rate.
  3. Sort by city_name, then month ascending.

Schema

cities
ColumnTypeDescription
city_idPKINTUnique city identifier
city_nameVARCHAR(100)Didi service city name
ride_requests
ColumnTypeDescription
request_idPKINTUnique ride request identifier
city_idINTRequested pickup city
requested_atTIMESTAMPTimestamp when the ride was requested
statusVARCHAR(20)Ride outcome, such as completed or cancelled
driver_sessions
ColumnTypeDescription
session_idPKINTUnique driver session identifier
city_idINTCity where the driver was available
driver_idINTDriver identifier
session_dateDATEDate of the driver session
online_minutesINTMinutes the driver was online
Tablescitiesride_requestsdriver_sessions
Interviewer

Your question is City Ride Demand SQL Analysis. Start with the requirements and the three 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.