代码如下:
WITH 表1 AS
(
SELECT 编号字段名, ROW_NUMBER() OVER(ORDER BY 排序字段名 DESC) AS RowNum
FROM 表名
)
Update 表1
SET 编号字段名=RowNum
应用场景:
通过这样的SQL语句根据小组人气值对小组进行排名:
代码如下:
WITH groups AS
(
SELECT RankNum, ROW_NUMBER() OVER(ORDER BY 人气值 DESC) AS RowNum
FROM club_Groups
)
Update groups
SET RankNum=RowNum
猜你喜欢