Click here to Skip to main content
15,902,888 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
my table Trn_NO credit debit Trn_Date,Cust_Code
closing balance and opening balance group by cust_Code

What I have tried:

my table Trn_NO credit debit Trn_Date,Cust_Code
closing balance and opening balance group by cust_Code
Posted
Updated 3-Sep-21 20:14pm
Comments
Wendelius 4-Sep-21 2:06am    
At the moment the question does not make sense. Use improve question to give more details like, what is the requirement, what have you done so far, and what issue you're running into.

1 solution

Use a GROUP BY to collect information by Cust_Code - get the opening balance date, and sum the credits and debits into separate result columns.
Then JOIN that result to your original table on Cust_Code and earliest date, and you can retrieve the opening balance directly, and generate the closing balance from that plus the credit sum less the debit sum.
 
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