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 |
|
Kalaiselvan
Posting Yak Master
112 Posts |
Posted - 2011-02-01 : 15:29:26
|
| Table A - Unique Records for a Member with Loan AmtEx: LoanAmt=10000 MemeberId=1Table B - Transaction table for Table A. which has 10 rows with Recieved Amt on Due DateEx: MemberId=1 DueDate Recieved Amt Jan 1 1000 Jan 2 1000 Jan 3 1000 Jan 4 1000 Jan 5 1000 Jan 6 1000 Jan 7 1000 Jan 8 1000 Jan 9 1000 Jan 10 1000SELECT MemeberName,LoanAmt,SUM(Recieved),(LoanAmt-(SUM(Recieved)) As PrincipleOutstandingFROM Table A INNER JOIN Table B ON A.MemberId=B.MemberIdGROUP BY MemeberName,LoanAmtOutstanding=LoanAmt-SUM(RecievedAmt)Ex: Outstanding=10000-SUM(RecievedAmt) 10000-10000=0But I Need the Outstanding Amt for Each Day:SELECT MemeberName,LoanAmt,DueDate,Recieved,(LoanAmt-(Recieved)) As PrincipleOutstandingFROM Table A INNER JOIN Table B ON A.MemberId=B.MemberIdGROUP BY MemeberName,LoanAmt,DueDate,RecievedFrom Above Calculation am getting as Jan 1 10000-1000=9000Jan 2 10000-1000=9000...............................................................Jan 10 10000-1000=9000The above Result is wrong. I need the Calculation Thru Query from the column. Output should beJan1 10000-1000=9000Jan2 9000-1000=8000Jan3 8000-1000=7000..........................................................Jan10 1000-1000=0Please help me in this to find the soln. Have to get from above columns not other than that...Regards,Kalaiselvan RLove Yourself First.... |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-02-11 : 10:10:16
|
| Search for Running total in this forumMadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|
|