SELECT PB.BUKTI_ID,
PB.BUKTI_DATE,
CBD.DISBURSE_DATE,
PB.CB_ID,
PB.BUKTI_RECEIVED_BY,
PB.NPWP,
(SELECT SUM (TOTAL_AMOUNT)
FROM TRX_PPH23_BUKTI PB
LEFT JOIN
TRX_PPH23_BUKTI_DETAIL PBD
ON PB.BUKTI_ID = PBD.REF_BUKTI_ID)
AS TOTAL_AMOUNT,
PB.BRANCH_ID,
DECODE (PB.BUKTI_STATUS, 'O', 'Open', 'B', 'Cancel', 'Close')
BUKTI_STATUS
FROM TRX_PPH23_BUKTI PB
LEFT JOIN
( (SELECT DISBURSE_NO,
DISBURSE_DATE,
RECEIVED_BY,
TOTAL_AMOUNT,
DISBURSE_STATUS
FROM TRX_CASH_DISBURSE_HEADER)
UNION
(SELECT DISBURSE_NO,
DISBURSE_DATE,
RECEIVED_BY,
TOTAL_AMOUNT,
DISBURSE_STATUS
FROM TRX_BANK_DISBURSE_HEADER)) CBD
ON PB.CB_ID = CBD.DISBURSE_NO
ORDER BY PB.BUKTI_ID DESC;
我想从其他表(TRX_PPH23_BUKTI_DETAIL)中选择字段总和(total_amount),但我对此列的值相同,
我知道问题因为我没有特别说密钥(bukti_id).. 但我不知道如何在没有存储过程+参数的情况下循环这个查询