I created a sample data table for your case.What you need to have is a date table with all the dates for your salary export (this is just a case). To populate a date table is very easy and fast.Otherwise solution is very straightforward. It created derived / temp table with all the dates and clients, later updated all the existing salaries and calculates cumulatives.--populate sample TABLEcreate table sal(date smalldatetime,client_code char(1),salary int)insert into salselect '2010/4/1','A',4000 union allselect '2010/4/1','B',6000 union allselect '2010/4/2','B',6000 union allselect '2010/4/4','A',6000 union allselect '2010/4/6','B',8000 union allselect '2010/4/6','A',2000--(6 row(s) affected)--POPULATE DATE TABLE --WILL BE NEEDED IN FURTHER STEPScreate table tbl_date(date smalldatetime)insert into tbl_dateselect '2010/4/1' union allselect '2010/4/2' union allselect '2010/4/3' union allselect '2010/4/4' union allselect '2010/4/5' union allselect '2010/4/6' --(6 row(s) affected)select d1.date ,x.client_code ,0 as salary into #temp from tbl_date as d1cross join (select distinct client_code from sal) as x--(12 row(s) affected)update tset t.salary = s.salaryfrom #temp as t join sal as s on s.client_code = t.client_code and s.date = t.date--(6 row(s) affected) -- CUMULATIVE RESULTS WITH NULL VALUES ROWSselect s1.date,s1.client_code,s1.salary,(select sum(salary) from #temp as s2 where s2.date <= s1.date and s1.client_code = s2.client_code) as sal_cumfrom #temp as s1order by s1.client_code, s1.date