3 insert into player_ranks_history
4 select * from player_ranks;
6 -- get rid of the existing ranks and refresh them using
7 -- the latest elo information for each game type
8 delete from player_ranks;
10 insert into player_ranks(player_id, nick, game_type_cd, elo, rank)
11 select p.player_id, p.nick, pe.game_type_cd, pe.elo, row_number()
12 over (partition by pe.game_type_cd order by pe.elo desc, pe.create_dt)
13 from players p, player_elos pe
14 where p.player_id = pe.player_id
15 and p.active_ind = True
16 and pe.active_ind = True