Forum Discussion
Trying to create Access report that subtracts payments from what is owed
- Mar 20, 2021
What you need is an aggregate query that sums the payments.
Here's how I would do that, based on the information available from your screen shots:
SELECT SPT.StudentID, SPT.PaymentBalance, Payments.PaidAmount, SPT.PaymentBalance - Payments.PaidAmount AS RemainingBalance
FROM StudentProfileTable AS SPT
Left Outer JOIN
(
SELECT StudentID, Sum([Payment]) AS PaidAmount
FROM PaymentTable
GROUP BY StudentID
) AS Payments ON SPT.StudentID = Payments.StudentID
What you need is an aggregate query that sums the payments.
Here's how I would do that, based on the information available from your screen shots:
SELECT SPT.StudentID, SPT.PaymentBalance, Payments.PaidAmount, SPT.PaymentBalance - Payments.PaidAmount AS RemainingBalance
FROM StudentProfileTable AS SPT
Left Outer JOIN
(
SELECT StudentID, Sum([Payment]) AS PaidAmount
FROM PaymentTable
GROUP BY StudentID
) AS Payments ON SPT.StudentID = Payments.StudentID
- George_HepworthMar 21, 2021Silver ContributorContinued success with your project.