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 |
|
poornima
Starting Member
32 Posts |
Posted - 2006-10-24 : 04:26:18
|
| HelloI have a table containing credit,debit,balance columns.Initially balance column has some value.Now if in credit column some value is entered,it should get added in the balance ,similarly if debit column has some value it should get subtracted.How do i manipulate this.Thanks In AdvancePoornima |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-10-24 : 04:36:26
|
| Can you post the table structure?MadhivananFailing to plan is Planning to fail |
 |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2006-10-24 : 04:47:25
|
| I reckon that you may be making life hard for yourself by storing the balance in the same table as credits and debits. Each credit and debit line should be a row in a seperate table, probably linked to the other table by customer ID.-------Moo. :) |
 |
|
|
poornima
Starting Member
32 Posts |
Posted - 2006-10-24 : 04:49:53
|
| The below one is the table structure,but here i have manually entered the balance.I want to get it updated by setting the formula.Also i want to change the date format.SNo Date Reason Credit Debit balance1 1905-06-16 00:00:00.000 Salary 5000.00 0.00 5000.002 1905-06-15 00:00:00.000 Salary 5000.00 0.00 10000.00 |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-10-24 : 04:59:15
|
| A balance that goes back in time?Peter LarssonHelsingborg, Sweden |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-10-24 : 05:05:25
|
| [code]SELECT q.SNo, CONVERT(varchar, q.Date, 102) Date, q.Reason, q.Credit, q.Debit, (SELECT SUM(x.Credit - x.Debit) FROM MyTable x WHERE x.Date <= q.Date) BalanceFROM MyTable q[/code]Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|
|