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
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Debit & Credit Balance Query

Author  Topic 

HaiderAli
Starting Member

1 Post

Posted - 2014-11-08 : 01:32:39
Hi Every One Im New Here..
Firstly I Say .. If Im Post In Wrong Section Then Plz Move My Post. Its My First Post.

Here Is My Question..
I Have Two Tables.
Please Tell Me How To Get Running Balance.
Im Also Read Other Related Topic But Im Failed To Understand Plz Solve My Problem.
Table Details Is Here !
Table 1 : Users
Fields Below.
UID
Name
Description
Table 2 : Balance
Fields Below.
BID
UID
Date
Dr
Cr
Description

Muj9
Yak Posting Veteran

75 Posts

Posted - 2014-11-10 : 10:43:01
Can you provide more details. what is your expected result? what do these fields contain? .....some example data would be more helpful
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-11-10 : 14:13:21
select sum(dr) over(partition by uid rows unbounded preceding),
sum(dr) over(partition by uid rows unbounded preceding),
Date
from table1 t1
join table2 t2 on t1.uid = t2.bid
order by date asc
Go to Top of Page
   

- Advertisement -