-4

如何获得这笔款项?

employer_payment.payment = employer_salary.salary - employer_advance_payment.advance_payment

在此处输入图像描述

请就我如何解决这个问题的问题给我你的建议?

4

1 回答 1

1

您可以使用LEFT JOIN来计算salary扣除的advance_payment

SELECT  a.employerID,
        a.salary - COALESCE(b.advance_payment, 0) payment
FROM    employer_salary a
        LEFT JOIN employer_advance_payment b
            ON a.employerID = b.employerID
于 2013-05-17T15:56:56.633 回答