sagadgfgfdgasdgagfdasd asdfgasg
fdsgsgfs afdgsdfga
Advertisement
Answer
This seems to be aggregation to get the totals for each player and name — and window functions to get the top one. Then a join
:
select pg.player_id, pg.game_id, g.game_name, pg.num_times from (select player_id, game_id, sum(num_times) as num_times, row_number() over (partition by player_id order by sum(num_times) desc) as seqnum from a group by player_id, game_id ) pg join b on pg.game_id = b.game_id where seqnum = 1;