You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- the concerpt is to unoin first and second player and scores because the match was between 2 players of the same group
-- for each group, there can only be 1 winner, so easier approach to convery everything to records
-- t- union all plaers and scores
-- cte- get group of each player, find sum of scores for each player, and assign rank for each group(partition) according to highest score and lower player_id in case of tie(order by)
-- final query- pull the players with rank = 1 from cte
with cte as
(select group_id, first_player, sum(first_score) as total_score,
dense_rank() over(partition by group_id order by sum(first_score) desc, player_id asc) as rnk