oracle中的逐行平衡
请参阅下面的代码、结果和预期结果oracle中的逐行平衡,oracle,Oracle,请参阅下面的代码、结果和预期结果 SELECT DISTINCT VW_PM_INV_BAL.invoice_no, VW_PM_INV_BAL.quote_section_id , paymatic_debtors_info.type, cl$invoices.total INVOICED_AMT, paymatic_debtors_info.amount PAID_CR_REV
SELECT DISTINCT VW_PM_INV_BAL.invoice_no,
VW_PM_INV_BAL.quote_section_id ,
paymatic_debtors_info.type,
cl$invoices.total INVOICED_AMT,
paymatic_debtors_info.amount PAID_CR_REV
FROM paymatic_debtors_info
left outer JOIN cl$invoices
ON cl$invoices.invoice_no = paymatic_debtors_info.ref
left outer JOIN VW_PM_INV_BAL
ON VW_PM_INV_BAL.invoice_no = cl$invoices.invoice_no
WHERE VW_PM_INV_BAL.quote_section_id = '1000065052'
ORDER BY 1, 2 DESC;
结果
Invoice_no Quote_section_id Type Invoiced Paid_CR_REV
729001 1000065052 Inv 70680 70680
729001 1000065052 Pmt 70680 -70680
732331 1000065052 Inv 21556.26 21556.26
732331 1000065052 Pmt 21556.26 -21556.26
751231 1000065052 Inv 21556.374 21556.37
751231 1000065052 Pmt 21556.374 -21556.37
753107 1000065052 Inv 21556.374 21556.37
753107 1000065052 Pmt 21556.374 -21556.37
753107 1000065052 Rev 21556.374 21556.37
期望
Invoice_no Quote_section_id Type Invoiced Paid_CR_REV Balance
729001 1000065052 Inv 70680
729001 1000065052 Pmt -70680 0
732331 1000065052 Inv 21556.26
732331 1000065052 Pmt -21556.26 0
751231 1000065052 Inv 21556.374
751231 1000065052 Pmt -21556.37 0
753107 1000065052 Inv 21556.374
753107 1000065052 Pmt -21556.37 0
753107 1000065052 Rev 21556.374 21556.374
您仅从查询中选择了五列。所选列表中没有余额列。你能再检查一下你的查询吗
SELECT DISTINCT VW_PM_INV_BAL.invoice_no , -- 1st column
VW_PM_INV_BAL.quote_section_id , -- 2nd column
paymatic_debtors_info.type, -- 3rd column
cl$invoices.total INVOICED_AMT, -- 4th column
paymatic_debtors_info.amount PAID_CR_REV -- 5th coulmn
FROM paymatic_debtors_info
请参见“未选择余额”列中的