C
clintonb
Here is a type of problem that has plagued me for way too long.
Let's say we have an account charge table that holds charges for an
account.
Table: AccountCharge
AccountNumber Charge
123 $125.00
123 $200.25
548 $86.00
Let's also say we have an account payment table that holds payments
for an account.
Table: AccountPayment
AccountNumber Payment
123 $100.00
548 $40.00
548 $46.00
How can I write a query that will give the balance for each account?
Account Number Balance
123 $225.25
548 $0.00
I'd like to somehow sum up the charges, sum up the payments and
subtract them using a single query. Right now I'm forced to write a
view to sum up the charges and write a second view to sum up the
payments, and then use a join query to join the views to do the
subtraction.
I'm assuming this must be a common problem that others have worked out
before.
Any help would be greatly appreciated.
Thanks!
- Clint
Let's say we have an account charge table that holds charges for an
account.
Table: AccountCharge
AccountNumber Charge
123 $125.00
123 $200.25
548 $86.00
Let's also say we have an account payment table that holds payments
for an account.
Table: AccountPayment
AccountNumber Payment
123 $100.00
548 $40.00
548 $46.00
How can I write a query that will give the balance for each account?
Account Number Balance
123 $225.25
548 $0.00
I'd like to somehow sum up the charges, sum up the payments and
subtract them using a single query. Right now I'm forced to write a
view to sum up the charges and write a second view to sum up the
payments, and then use a join query to join the views to do the
subtraction.
I'm assuming this must be a common problem that others have worked out
before.
Any help would be greatly appreciated.
Thanks!
- Clint