日期:2014-05-18 浏览次数:20498 次
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