RankedMatches
CTE:
ROW_NUMBER()
to generate two sequences of row numbers for each player's matches.streak_group
identifier by subtracting these sequences.1
using a CASE
statement.Streaks
CTE:
streak_group
using SUM()
and a window function.player_id
and the maximum streak length for each player.CASE
statement to ensure only streaks of wins are considered.player_id
to find the longest streak for each player.erDiagram Matches { int player_id date match_day enum result player_id match_day PK }