【leetcode】 178. Rank Scores

mysql中變量

@i 表示變量,i爲變量名,可以任意命名
@i := 0 變量賦值

如果想了解更多,百度一下有很多blog

答案

select Score, (@i := @i + (@pre <> (@pre := Score))) as Rank from Scores, (select @i:=0, @pre:=-1) init order by Score desc;

參考

https://www.cnblogs.com/rever/p/7149995.html

練習

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章