Sql server 使用自动递增序列号Sql server进行分组

Sql server 使用自动递增序列号Sql server进行分组,sql-server,Sql Server,我已附上一张带有我的问题的图片,请帮助我…… select *,row_number() over(partition by Test_ID order by Test_id) as [#no] from table_name 如果表中已经存在列[#no],并且如果要更新它,请使用下面的查询 将组Id作为主键处理 update t1 set t1.[#no]=t2.[#no] from table_name t1 inner join (select Group_Id,row_number(

我已附上一张带有我的问题的图片,请帮助我……

select *,row_number() over(partition by Test_ID order by Test_id) as [#no]
from table_name
如果表中已经存在列[#no],并且如果要更新它,请使用下面的查询

将组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

“,”在“*”之后是必需的??您还需要一个。(不是test_id-group id或name)@luv:它显示的“排名函数”行数必须有一个ORDER BY子句“图片中的问题???这对搜索此站点的任何其他人都是无用的。请在提问时多加努力。到目前为止你试过什么?你犯了什么错误?这表明你没有努力解决问题!