Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
i have a table
field are
acc_code,acc_desc, debit, credit
i want result lik
acc_desc,debit,credit, balance
AC_DESC,200,0, 200
AC_DESC,0 100, 100
kingdly anyone give me sql query?
what will be query?

What I have tried:

select acc_desc, debit, credit , debit-credit balance
where acc_code = 1001
Posted
Updated 25-Jan-18 3:40am
v3
Comments
Animesh Datta 25-Jan-18 7:06am    
what out put you are getting ?

Have a look at Wendelious' article here on CodeProject ... Calculating simple running totals in SQL Server[^]
 
Share this answer
 
If you want debit credit data in correct sequence the you can a a DateTime column
E.G.
acc_code,acc_desc, debit, credit , [CreationDateTime]

the use Select Statement
Select
acc_desc,
debit,
credit ,
debit,
credit,
balance
where acc_code = [YourCode] order by [CreationDateTime]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900