请谁能告诉我为什么下面的代码不从扣除表中计算金额,然后从出勤表中的金额总和中扣除以获得净工资。在应用扣除之前,它不会将出勤表中的金额总和加倍,而不是相加和扣除,我非常感激。
select sum(attendance.amount) - max(deduction.amount)
from attendance
join deduction on attendance.staffid = deduction.staffid
where attendance.staffid = some_staffid
and month(attendance.date) = some_month
and month(deduction.date_approved) = some_month