早上好,用这个把我的头撞到墙上,希望能得到一些建议。我有 3 个表加入以显示销售数据,如下所示;
Select
a._CommMonth As Month,
Sum(a._CommDue) As Commission,
Sum(a.`Network Paid`) As Company,
Sum(a.Payable) As Adviser,
c.Fee As Charge,
Sum(a.Payable) - (c.Fee) As Total
From
pms_payments.dbo_payments a
Inner Join pms_payments.dbo_nscontacts b
On b._Firm_Name = a._Firm_Name
Left Join pms_payments.dbo_clawback c
On b.ContactID = c.ContactID And a._CommMonth = c.Month
Where
b.ContactID = 199
Group By
a._CommMonth
Sum(a.Payable) - (c.Fee) As Total 字段是我遇到问题的地方,如果 c.fee 表中不存在任何记录,则不会返回任何内容,例如 100 - [No record] = 100。如果记录存在的值按预期扣除,例如 100 - 15 = 85。
那有意义吗?
谢谢