34,836
社区成员




declare @t table(d datetime,e int)
insert @t select '2007-12-1',1
insert @t select '2007-12-2',1
insert @t select '2007-12-3',1
insert @t select '2007-12-4',1
insert @t select '2007-12-5',1
insert @t select '2007-12-6',1
insert @t select '2007-12-7',1
select d,(select sum(e) from @t where d<= a.d)
from @t a
/*
d
------------------------------------------------------ -----------
2007-12-01 00:00:00.000 1
2007-12-02 00:00:00.000 2
2007-12-03 00:00:00.000 3
2007-12-04 00:00:00.000 4
2007-12-05 00:00:00.000 5
2007-12-06 00:00:00.000 6
2007-12-07 00:00:00.000 7
(所影响的行数为 7 行)
*/