27,580
社区成员
发帖
与我相关
我的任务
分享
with t as
(select row_number() over(order by getdate()) 'rn',
colum1,colum2 from test
)
select t1.colum1,
(select sum(t2.colum2) from t t2 where t2.rn<=t1.rn) '累计'
from t t1
/*
colum1 累计
-------------------- -----------
11 11
22 33
44 77
55 110
33 154
(5 row(s) affected)
*/