Query : AP to GL data transfer

SELECT details."Vendor_Num", details."Vendor_Name", details."Prepayment_Num", details."Prepayment_Currency", details."Prepayment_Amount" "Prepayment_Amount", SUM (details."Apply_Amount") "Apply_Amount_Sum" FROM (SELECT pv.segment1 "Vendor_Num", pv.vendor_name "Vendor_Name", ai1.invoice_num "Prepayment_Num", ai1.invoice_currency_code "Prepayment_Currency", ai2.invoice_num "Invoice_Num", ai2.invoice_currency_code "Invoice_Currency", ...