Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
paulaziz
Starting Member
1 Post |
Posted - 2012-04-26 : 22:17:58
|
I have a table that stores transactions for income and expenditure. the fields of the table are:transid, accountcredited, accountdebited, date, amount. Every transaction has double entry; it debits one account and credit another.The accountcredited and accountdebited are linked to accounts table(the fields for accounts table are accid, accountno, balance)The problem is I cannot figure out sql statemet to generate running balance. Any help would greatly appreciatedThanks in advancePA |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-04-26 : 22:22:22
|
what is the required result like ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-27 : 16:21:00
|
sounds like a trigger to me to modify account tables automatically------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
pphillips001
Starting Member
23 Posts |
Posted - 2012-04-30 : 05:15:17
|
There are many examples of tsql cumulative totals on the web - have you tried searching?For this there are four approaches that I can recall: Nested sub-query, Self join, Cursor and Update to local variable. The last one is by far the most efficient.===========================There is no reality - only perspective. |
 |
|
|
|
|