create table # (dt varchar(10),[count] int)
insert into #
select '2006-01-01',1
union all
select '2006-01-02',3
union all
select '2006-01-03',6
union all
select '2006-01-04',3
go
select sum([count]) from #
go
select *,(select sum([count]) from # where datediff(second,dt,a.dt)>=0) from # a
create table # (d int identity(1,1) ,dt varchar(10),[count] int)
insert into #
select '2006-01-01',1
union all
select '2006-01-02',3
union all
select '2006-01-03',6
union all
select '2006-01-04',3
go
select sum([count]) from #
go
select *,(select sum([count]) from # where datediff(second,dt,a.dt)>=0 and d<=a.d ) from # a
var i,j,CountValue;
begin
adoq.sql.text:='select * from TABEL1';
adoq.exesql;
if adoq.RecordCount<=1 then
begin
exit;
end
else
begin
for i:=2 to RecordCount do
begin
j:=adoq.RecNo;
adoq.RecNo:=adoq.RecNo-1;
CountValue:=adoq.FieldByName('count').AsInteger;
adoq.RecNo:=j;
adoq.FieldByName('count').AsInteger:=adoq.FieldByName('count').AsInteger+CountValue;
adoq.next;
end;
end;
end;