I see that you're using SQL Server, read this link about counting rolling total - Calculate a Running Total in SQL Server.
Fastest way in 2012 - to use sum(...) over (order by ...), in 2008 - use CTE with sequential row_numbers
So, if nulls after largest sum is not critical, you could do (it's not the fastest way, but for fast cte you have to create table with sequential number without gaps).
;with cte as (
select
T1.First_mob,
sum(T2.[r2009]) as [r2009],
sum(T2.[r2010]) as [r2010],
sum(T2.[r2011]) as [r2011],
sum(T2.[r2012]) as [r2012],
sum(T2.[r2013]) as [r2013]
from Table1 as T1
left outer join Table1 as T2 on T2.First_mob <= T1.First_mob
group by T1.First_mob
)
select
c1.First_mob,
c1.[r2009] as [r2009],
c1.[r2010] as [r2010],
c1.[r2011] as [r2011],
c1.[r2012] as [r2012],
c1.[r2013] as [r2013]
from cte as c1
see sql fiddle example
update the query is a bit weird, but it's because I've made unpivot so I could not to specify all column names everywhere. May be it would be possible to make it more effecient, but now I have this:
;with cte1 as (
-- unpivoting columns to rows so we could write general queries
select
T1.First_mob,
C.Name, C.Value
from Table1 as T1
cross apply (
select 'r2009', [r2009] union all
select 'r2010', [r2010] union all
select 'r2011', [r2011] union all
select 'r2012', [r2012] union all
select 'r2013', [r2013]
) as C(Name, Value)
), cte2 as (
-- counting running total
select
c1.First_mob, c1.Name, c1.Value, sum(c2.Value) as Total_Value
from cte1 as c1
inner join cte1 as c2 on c2.First_mob <= c1.First_mob and c2.Name = c1.Name
group by c1.First_mob, c1.Name, c1.Value
), cte3 as (
-- counting total sums (need later)
select
c1.Name, sum(c1.Value) as Value
from cte1 as c1
group by c1.Name
), cte4 as (
-- removing all unnecessary values
select
c2.First_mob,
c2.Name,
case when c3.Value = c2.Total_Value and c2.Value is null then null else c2.Total_Value end as Value
from cte2 as c2
inner join cte3 as c3 on c3.Name = c2.Name
)
-- pivoting rows to columns
select
c4.First_mob,
max(case when C4.Name = 'r2009' then C4.Value end) as [r2009],
max(case when C4.Name = 'r2010' then C4.Value end) as [r2010],
max(case when C4.Name = 'r2011' then C4.Value end) as [r2011],
max(case when C4.Name = 'r2012' then C4.Value end) as [r2012],
max(case when C4.Name = 'r2013' then C4.Value end) as [r2013]
from cte4 as c4
group by c4.First_mob
see sql fiddle with example