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 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.
| Column | Type | Description |
|---|---|---|
| driver_idPK | INT | Unique driver identifier |
| signup_date | DATE | Date the driver account was created |
| city | VARCHAR(50) | Driver onboarding city |
| bank_account_id | VARCHAR(30) | Payout bank account identifier |
| referral_code | VARCHAR(20) | Referral code used during signup |
| Column | Type | Description |
|---|---|---|
| check_idPK | INT | Unique background check event |
| driver_id | INT | Driver associated with the check |
| check_date | DATE | Date of the background check result |
| result | VARCHAR(20) | Background check result |
| Column | Type | Description |
|---|---|---|
| ride_idPK | INT | Unique ride identifier |
| driver_id | INT | Driver assigned to the ride |
| ride_date | DATE | Date the ride occurred |
| status | VARCHAR(20) | Ride outcome status |
| gross_bookings | NUMERIC(10,2) | Gross bookings amount for the ride |