select counter, emp_short, trans_date, debit, credit, (select sum(coalesce(debit,0) - coalesce(credit,0)) from trans02 tr2 where tr2.counter <= tr1.counter and tr2.emp_short = tr1.emp_short) as 'Running balance' from trans02 tr1 order by emp_short, counter; go