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
Flag Suspicious Lyft Trip Cards
00:00
5 left

Flag Suspicious Lyft Trip Cards

MediumSQL · PostgreSQL

Problem

You are given Lyft trip transaction data and need to identify payment cards showing patterns that may indicate fraud. Write a SQL query that returns cards with suspicious activity in the last 7 days based on trip behavior and payment outcomes. A card should be flagged if it has at least 3 declined attempts, or if it has trips in at least 3 distinct cities, or if its total approved spend exceeds 500 in that 7-day window. Return the card, rider, counts of approved and declined trips, distinct city count, approved spend, and a fraud flag reason.

Schema

trip_transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction identifier
trip_idINTTrip associated with the payment event
rider_idINTRider who initiated the trip
card_idINTPayment card used for the trip
transaction_tsTIMESTAMPTransaction timestamp
amount_usdNUMERIC(10,2)Transaction amount in USD
payment_statusVARCHAR(20)Payment outcome such as approved, declined, or pending
riders
ColumnTypeDescription
rider_idPKINTUnique rider identifier
rider_nameVARCHAR(100)Rider full name
home_cityVARCHAR(50)Rider home city
trips
ColumnTypeDescription
trip_idPKINTUnique trip identifier
cityVARCHAR(50)City where the trip occurred
ride_typeVARCHAR(30)Lyft ride type
requested_atTIMESTAMPTrip request timestamp
Tablestrip_transactionsriderstrips
Interviewer

Your question is Flag Suspicious Lyft Trip Cards. 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.