--CREATE TABLE huang (id INT ,class INT,VALUE int)
--INSERT INTO Huang
--SELECT 7,1,NULL
--UNION ALL
--SELECT 8,1,NULL
--UNION ALL
--SELECT 3,1,NULL
--UNION ALL
--SELECT 4,2,NULL
--UNION ALL
--SELECT 5,2,NULL
--UNION ALL
--SELECT 6,2,NULL
SELECT id,class,RANK()OVER(PARTITION BY class ORDER BY id)VALUE
FROM Huang
是可以查询,不过我是要修改那个value的值 修改成那样 ------其他解决方案-------------------- ;with cte as (SELECT id,class,RANK()OVER(PARTITION BY class ORDER BY id)VALUE
FROM Huang)
update tb
set a.value=b.value
from tb a inner join cte b on a.id=b.id ------其他解决方案--------------------