Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL for High-Value Betting Users
00:00
5 left

SQL for High-Value Betting Users

MediumSQL · PostgreSQL

Problem

Write a SQL query to identify high-value users based on specific betting patterns over the last 90 days. Treat a high-value user as one with at least five settled bets, at least 1000 in total stake, bets across both single and parlay types, and a win rate of at least 60%.

Output

  1. One row per qualifying user with user_id, username, settled_bet_count, total_stake, win_rate, and betting_patterns.
  2. Include only qualifying users, ordered by total_stake descending, then user_id ascending.

Schema

users
ColumnTypeDescription
user_idPKINTUnique user identifier
usernameVARCHAR(100)User display name
bets
ColumnTypeDescription
bet_idPKINTUnique bet identifier
user_idINTUser who placed the bet
placed_atDATEDate the bet was placed
bet_typeVARCHAR(20)Bet pattern, such as single or parlay
stakeNUMERIC(12,2)Amount staked on the bet
statusVARCHAR(20)Settlement status of the bet
outcomeVARCHAR(20)Bet result, such as won or lost
Tablesusersbets
Interviewer

Your question is SQL for High-Value Betting Users. 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.