So I two groups tblTenant.ID tblTransaction.TenantID
In tblTransactions there are two fields I want to manipulate, AmountCharged and AmountPaid. How can I sum both fields and subtract them per group? I.E., each Tenant will have all their amountCharged's summed and then have their AmountPaid's summed and subtracted.
For example, the SQL would be:
SELECT SUM(tblTransactions.AmountCharged) - SUM(tblTransactions.AmountPaid) FROM tblTransactions
Where tblTrascactions.TenantID = x
Where 'x' is the tenant id of the group.