I just fail to understand why it is not possible using normal CTEdeclare @tbl as table(id int ,Office varchar(40),amount int)insert into @tblselect 1,'Office1', 1000 union allselect 2,'Office1' ,500 union allselect 3,'Office1', 1000 union allselect 4,'Office2', 1000 union allselect 5,'Office2', 1000 union allselect 6,'Office2', 1000 union allselect 7,'Office3', 1000 union allselect 8,'Office3', 1000 union allselect 9,'Office3', 1000 union allselect 10,'Office3',1000 ;with cteas(select Office,id,amount,amount as amt from @tblunion allselect t.Office,t.id,t.amount,(t.amount+c.amt) as amt from @tbl as tinner join cte c on t.id=c.id+1 and t.Office=c.Office)select * from cte order by office
Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH