Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Daily Peak-Hour Driver Acceptance Rate

MediumSQL · PostgreSQL00:00
I
Practice interviewer
Your interviewer
In session
I
Interviewer

Welcome to the SQL screen.

The question is on your right: Daily Peak-Hour Driver Acceptance Rate. Read through the requirements and the three tables first.

Run and submit your code as often as you need. You also have five interviewer messages this session - want to talk through your approach, or are you ready to start coding?

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