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 |
assiff79
Starting Member
7 Posts |
Posted - 2014-07-19 : 05:11:15
|
i have a talbledebit credit totalcredit25 10 1020 35 4530 40 85look at 3rd colum 10=10 10+35 =45 40+45 =85i want such results and also insertion statementasif |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-07-19 : 05:21:42
|
[code]; with cte as( select rn = row_number() over (order by <some column>), debit, credit from talble)select debit, credit, totalcredit = (select sum(credit) from cte x where x.rn <= c.rn)from cte corder by rn[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-07-19 : 06:31:52
|
just add the INSERT statement before the SELECT line to insert into your required table KH[spoiler]Time is always against us[/spoiler] |
|
|
|
|
|