【发布时间】:2017-10-28 10:22:52
【问题描述】:
SELECT tblStudent.student_id,
[monthly_fee]+[book_fee] AS [Total Fee],
Sum(tblReceipt.receipt_amount) AS SumOfreceipt_amount,
[monthly_fee]+[book_fee]-Nz(Sum([tblReceipt]![receipt_amount]),0) AS Outstanding,
tblReceipt.month,
tblReceipt.year
FROM tblStudent
LEFT JOIN tblReceipt ON tblStudent.student_id = tblReceipt.student_id
GROUP BY tblStudent.student_id,
[monthly_fee]+[book_fee],
tblReceipt.Description,
tblReceipt.month,
tblReceipt.year
HAVING (((Sum(tblReceipt.receipt_amount))>0)
AND ((tblReceipt.Description)='Total Fee')
AND (([monthly_fee]+[book_fee]-Nz(Sum([tblReceipt]![receipt_amount]),0))>0)
AND ((tblReceipt.month)=[Forms]![frmDialogMonth3]![cb_Month])
AND ((tblReceipt.year)=[Forms]![frmDialogMonth3]![txt_Year]))
OR (((Sum(tblReceipt.receipt_amount)) IS NULL))
ORDER BY tblStudent.student_id;
你好,
请在附件中找到包含数据的示例表和上面的 sql 语句。 我想创建一个报告来显示未支付和未全额支付当月总费用(描述 = 总费用)的学生,包括他们当月的未付金额。
我得到的结果只显示未全额支付总费用的学生,以及在 tblReceipt 中没有任何记录的学生。那些在 tblReceipt 中的记录不是 Total Fee 的学生没有出现在结果中。
请在下面找到示例结果。
【问题讨论】: