178. Rank Scores

  • 0

    Perform select distinct on Scores:

    select distinct Score from Scores

    Then JOIN with table defined above on rows with greater Score and count joined rows:

    select max(a.Score) as Score,count(b.Score)+1 as Rank
    from Scores a
    left join 
    (select distinct Score from Scores) b
    on a.Score<b.Score
    group by a.Id
    order by a.Score desc

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.