Your question is Detect Consecutive Losing Streaks. Start with the requirements and the one table 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.
Given a table of user betting logs, write a query to identify consecutive losing streaks exceeding a specific threshold for risk assessment.
Assume the threshold is more than 3 consecutive losing bets. A win or a missing result ends the current losing streak.
user_id, streak_start, streak_end, and losing_bets.user_id, then streak_start, then streak_end.| Column | Type | Description |
|---|---|---|
| bet_idPK | INT | Unique identifier for the bet |
| user_id | INT | Identifier of the bet365 user |
| bet_timestamp | TIMESTAMP | Time when the bet was settled |
| outcome | VARCHAR(20) | Bet result, such as loss, win, or void |
| stake | NUMERIC(10,2) | Amount staked on the bet |