Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Summarize Lyft Trip Operations by City

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

Your question is Summarize Lyft Trip Operations by City. Start with the requirements and the two 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 Lyft trip records and city metadata. Write a PostgreSQL query that cleans inconsistent trip status values, joins each trip to its city, and summarizes operational performance by city for January 2024. Use the cleaned status logic to count completed trips and calculate completed-trip revenue, while excluding canceled and unknown statuses from the completed metrics.

Schema

trips
ColumnTypeDescription
trip_idPKINTPrimary key for each trip
city_idINTCity identifier for the trip
trip_dateDATEDate the trip occurred
statusVARCHAR(20)Raw trip status, may contain inconsistent casing or whitespace
fare_amountDECIMAL(10,2)Fare charged for the trip; can be NULL
cities
ColumnTypeDescription
city_idPKINTPrimary key for city metadata
city_nameVARCHAR(100)City name
regionVARCHAR(50)Region for reporting
Tablestripscities
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results