Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Flag Suspicious Driver Signup Clusters

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

Welcome to the SQL screen.

The question is on your right: Flag Suspicious Driver Signup Clusters. 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 the task of identifying potentially fraudulent Lyft driver accounts based on signals in the first 7 days after signup. Write a PostgreSQL query that returns drivers who look suspicious because they share a payout bank account with another driver, have multiple failed background checks, or generate unusually high ride cancellation activity shortly after onboarding. Return one row per driver with the driver ID, signup date, count of distinct drivers sharing the same bank account, failed background check count, cancellation rate in the first 7 days, and a final fraud flag.

Use only drivers who signed up in January 2024. A driver should be flagged when they meet at least two of these conditions: shared bank account with at least 2 drivers total, at least 2 failed background checks, or cancellation rate above 40% in the first 7 days.

Schema

drivers
ColumnTypeDescription
driver_idPKINTUnique driver identifier
signup_dateDATEDate the driver account was created
cityVARCHAR(50)Driver onboarding city
bank_account_idVARCHAR(30)Payout bank account identifier
referral_codeVARCHAR(20)Referral code used during signup
background_checks
ColumnTypeDescription
check_idPKINTUnique background check event
driver_idINTDriver associated with the check
check_dateDATEDate of the background check result
resultVARCHAR(20)Background check result
rides
ColumnTypeDescription
ride_idPKINTUnique ride identifier
driver_idINTDriver assigned to the ride
ride_dateDATEDate the ride occurred
statusVARCHAR(20)Ride outcome status
gross_bookingsNUMERIC(10,2)Gross bookings amount for the ride
Tablesdriversbackground_checksrides
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results