Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Daily Peak-Hour Driver Acceptance Rate

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

Your question is Daily Peak-Hour Driver Acceptance Rate. Start with the requirements and the three 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

You are given ride request and driver response data from Lyft. Write a query to calculate the daily driver acceptance rate for rides requested in San Francisco during peak hours. Treat peak hours as 7:00-9:59 and 16:00-18:59 based on the ride request timestamp. The acceptance rate should be the number of requested rides with at least one accepted driver response divided by the total number of qualifying ride requests for each day.

Schema

ride_requests
ColumnTypeDescription
request_idPKINTUnique ride request identifier
rider_idINTRider who placed the request
requested_atTIMESTAMPTimestamp when the ride was requested
city_idINTCity where the ride was requested
ride_typeVARCHAR(50)Requested Lyft product type
cities
ColumnTypeDescription
city_idPKINTUnique city identifier
city_nameVARCHAR(100)City name
state_codeVARCHAR(10)State abbreviation
driver_responses
ColumnTypeDescription
response_idPKINTUnique driver response identifier
request_idINTRide request tied to the response
driver_idINTDriver who received the request
response_statusVARCHAR(20)Driver response outcome
responded_atTIMESTAMPTimestamp of the driver response
Tablesride_requestscitiesdriver_responses
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results