Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL for Bet Customer Segments

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

Your question is SQL for Bet Customer Segments. 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

FanDuel Sportsbook wants to identify customers with consistently high win rates. Write a PostgreSQL query that finds customers whose winning bets represent at least 60% of their qualifying settled bets.

Requirements

  1. Count only bets with status = 'settled' and an outcome of won or lost.
  2. Require at least 3 qualifying settled bets per customer.
  3. Return the customer ID, name, settled bet count, winning bet count, and win percentage rounded to two decimals.
  4. Sort by win percentage descending, then customer ID ascending.

Schema

customers
ColumnTypeDescription
customer_idPKINTEGERUnique FanDuel customer identifier
customer_nameVARCHAR(100)Customer display name
bets
ColumnTypeDescription
bet_idPKINTEGERUnique bet identifier
customer_idINTEGERCustomer who placed the bet
statusVARCHAR(20)Bet status, such as settled or void
outcomeVARCHAR(20)Final result of the bet
Tablescustomersbets
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results