178.Rank Scores


  • 0
    L

    主要是通过disinct去重,通过@num生成序列号
    select Scores.Score,rank from Scores left join
    (select @num:=@num+1 as rank,Score from (select distinct Score from Scores order by Score desc) AS sc,(select @num:=0) as it) as final on Scores.Score=final.Score order by final.Score desc;


Log in to reply
 

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