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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 adding prevous value to present value in sql serve

Author  Topic 

ranga.402
Starting Member

1 Post

Posted - 2010-12-07 : 00:25:53
my syntax is like that.



Declare @temp table
(
SlNo int identity(1,1) not null,
Debit int null,
Credit int null,
Balance int null
)



insert @temp(Debit,Credit)
(select CurrentDebit,CurrentCredit from Account)







the temp table contained this data



slno debit crdit Balance

------+------+----------

1 | 10 | 0 null

2 | 0 | 40 null

3 | 50 | 0 null

4 | 0 | 10 null

5 | 0 | 10 null





the out put will be come like this

slno debit crdit Balance

------+------+----------

1 | 10 | 0 10

2 | 0 | 40 -30

3 | 50 | 0 20

4 | 0 | 10 -10

5 | 0 | 10 0



now how i can write quary for this


Thank's in advance

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-12-07 : 00:31:06
Have a look at:
http://www.sqlservercentral.com/articles/T-SQL/62159/

What version of SQL you are using ?
Go to Top of Page
   

- Advertisement -