我附上了我的问题的图片,请帮助我......
答案 0 :(得分:1)
<强> Use Ranking Functions 强>
select *,row_number() over(partition by Test_ID order by Test_id) as [#no]
from table_name
如果表格中已存在 [#no] 列,并且您希望更新,请使用以下查询
将 Group_Id
视为主键
update t1
set t1.[#no]=t2.[#no]
from table_name t1
inner join
(select Group_Id,row_number() over(partition by Test_ID order by Test_id) as [#no]
from table_name)t2 on t1.Group_Id=t2.Group_Id