34,590
社区成员
发帖
与我相关
我的任务
分享
declare @t table
(AI int not null,
BI varchar(4) not null
)
insert into @t
select 11,'KN' union all
select 11,'SU' union all
select 23,'MM' union all
select 90,'DD'
declare @n int
set @n = 10
;with t as (
select row_number() over(order by AI ,BI ) as ID,*,@n as n from @t
)
select *,(select sum(n) from t b where b.id <= a.id) from t a