So I two groups tblTenant.ID tblTransaction.TenantID
在tblTransactions有两个领域我想操纵,AmountCharged AmountPaid。我怎么能和字段和减去他们每组?即,每个租户将他们所有的amountCharged总结,然后有他们AmountPaid年代总结和减去。
例如,SQL将:
SELECT SUM(tblTransactions.AmountCharged) - SUM(tblTransactions.AmountPaid) FROM tblTransactions
Where tblTrascactions.TenantID = x
其中x是租户id。