For this you do not need to join . You can use accumulation.
If I understand correctly:
select userAcc, game, amount, isnull( (case when rn = 1 then max(case when rk = 1 then rn end) over (partition by userAcc) end),0) as newcol from (select t.*, ROW_NUMBER() OVER (PARTITION BY userAcc ORDER BY game) as rn, RANK() OVER (PARTITION BY userAcc ORDER BY amount DESC) as rk from
Gordon linoff
source share