这是我的查询和分组,按交易类型 C 表示贷方,D 表示借方和
SELECT
case
WHEN ACT.TRANSACTIONTYPE='C' THEN SUM(ACT.AMOUNT) END AS CreditBalance,
case
WHEN ACT.TRANSACTIONTYPE='D' THEN SUM(ACT.AMOUNT) END AS DebitBalance
FROM accounttransaction ACT
WHERE ACT.TRANSACTIONTYPE IS NOT NULL
GROUP BY ACT.TRANSACTIONTYPE;
下面是我的结果
CreditBalance DebitBalance
16536 NULL
NULL 9673
现在我想减去 A/C 的余额,然后我需要显示为 Current Balance Account 交易表包括 Accountnumber、transactiontype 和 amount