Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个Marks表,其中有一个列tags_score,我想使用Order BY Marks_score Desc使用选择查询添加一个 Rank 列。
我不知道如何使用 RANK() SQL 函数
提前致谢!!!
用这个:
RANK() OVER (ORDER BY TOTAL_CNT DESC DESC) 作为排名
select t1.*,RANK() OVER (ORDER BY t1.Marks_score DESC) AS Rank from Marks as t1
试试这个:
SELECT *,RANK() OVER (order by marks_score desc) as rnk FROM Marks
您可以在此处找到更多示例
同样的方式您可以使用 ROW_NUMBER()、DESNSE_RANK() 函数..
请阅读本文以找出它们之间的区别