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
Summarize Lyft Trip Operations by City
00:00
5 left

Summarize Lyft Trip Operations by City

HardSQL · PostgreSQL

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
Interviewer

Your question is Summarize Lyft Trip Operations by City. 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.