Hi,
I would like to update the #RunningTotal table, field RunningTotal with the result of the select below and the field total
Many thanks,
Pepe
CREATE TABLE #RunningTotal
(CL int, fecha date, Entry int ,RunningTotal int)
INSERT INTO #RunningTotal (cl ,fecha ,Entry,RunningTotal)VALUES(1,'2015-01-03',100,NULL)
INSERT INTO #RunningTotal (cl ,fecha ,Entry,RunningTotal)VALUES(1,'2015-02-03',200,NULL)
INSERT INTO #RunningTotal (cl ,fecha ,Entry,RunningTotal)VALUES(1,'2015-05-03',300,NULL)
INSERT INTO #RunningTotal (cl ,fecha ,Entry,RunningTotal)VALUES(1,'2015-07-13',400,NULL)
INSERT INTO #RunningTotal (cl ,fecha ,Entry,RunningTotal)VALUES(1,'2015-01-03',-500,NULL)
INSERT INTO #RunningTotal (cl ,fecha ,Entry,RunningTotal)VALUES(1,'2014-08-03',100,NULL)
select cl, entry, fecha, sum(entry) OVER (order by fecha) as Total
from #RunningTotal
where cl=1
order by fecha asc
drop table #RunningTotal