REDCap数据库计算不同记录中字段的平均值

时间:2019-01-23 16:10:22

标签: sql database sum average dynamic-queries

我的问题很简单。

我想在数据库中添加一些函数以直接通过数据输入返回结果。

为此,我需要能够使用Party_BalanceSELECT 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系统有可能吗?

0 个答案:

没有答案