If this is a simple debit/credit problem, here is one of the way to solve. I have tried creating a sample table called "Account".
create table Account(id int identity, F1 int, F2 int,F3 int)
insert into Account(F1,F2)
values
(20000,0),
(0,5000),
(55000,0),
(0,60000),
(0,20000),
(11000,0)
select id,F1,F2,(select SUM(F1-f2) from Account where id <=a.id) F3 from Account a
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter