For below Sql server 2012 using recursive CTE
declare @t table(id int,IDs varchar(20),Dates varchar(20),Cumulative int)
insert into @t values
(1,'x','Jan-10', 10)
,(3,'x','Feb-10', 40)
,(7,'x','Apr-10', 60)
,(9,'x','May-10', 100)
,(2,'y','Jan-10', 20)
,(6,'y','Mar-10', 40)
,(8,'y','Apr-10', 60)
,(10,'y','May-10',100)
;With CTE as
(select *,row_number()over(partition by ids order by id)rn
from @t
)
,CTE1 as
(select id,ids,dates, Cumulative,rn,Cumulative Reversed
from cte where rn=1
union all
select c.id,c.ids,c.Dates,c.Cumulative,c.rn
,c.Cumulative-c1.Cumulative
from cte c
inner join cte c1 on c.ids=c1.ids
where c.rn=c1.rn+1
)
select * from cte1