SQL語句如下:
復制代碼 代碼如下:
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