我的问题很简单。
我想在数据库中添加一些函数以直接通过数据输入返回结果。
为此,我需要能够使用Party_Balance
和SELECT pur.party_id, pur.total - pay.sumamount AS Party_Balance FROM (
SELECT Party.party_id, SUM(Purchase.total) AS total
FROM Party INNER JOIN Purchase ON Party.party_id = Purchase.supplier_id
GROUP BY Party.party_id
) AS pur
INNER JOIN (
SELECT Party.party_id, SUM(amount) AS sumamount
FROM Party INNER JOIN Payments ON Party.party_id = Payments.party_id
GROUP BY Party.party_id
) AS pay
on pay.party_id = pur.party_id
SQL函数。 REDCap系统有可能吗?