SQL2005 sorts the numbers according to the specified fields

Time:2019-12-26

The SQL statement is as follows:

Copy codeThe code is as follows:
WITH Table 1 AS
(
Select number field name, row_number() over (order by field name DESC) as rownum
FROM table name
)
Update Table 1
Set number field name = rownum

Application scenario:
The group is ranked according to the group popularity value through such SQL statement:

Copy codeThe code is as follows:
WITH groups AS
(
Select ranknum, row_number() over (order by value DESC) as rownum
FROM club_Groups
)
Update groups
SET RankNum=RowNum