SELECT ct.org_id ,ct.attribute1 bu_id --覈算主體編號 ,ct.attribute2 dept_id --部門編號 ,hca.account_number ,hp.party_name --收單方 ,ct.attribute3 --項目編號 ,pa.long_name --項目 ,to_char(ct.trx_date) trx_date ,to_char(gd.gl_date) gl_date ,ct.trx_number --編號 ,rc.name --事務處理類型 ,ct.invoice_currency_code --幣種 ,ct.exchange_rate --匯率 ,hp.attribute2 group_customer --集團客戶 ,ct.attribute8 final_customer_code --最終客戶 ,zl.tax_rate_code tax_rate_code --稅率名稱 ,zl.tax_amt tax_amt --稅額 ,ct.attribute15 outside_system --外圍系統ID FROM ra_cust_trx_types_all rc, ar.ra_customer_trx_all ct, ra_cust_trx_types_all ctt, ra_cust_trx_line_gl_dist_all gd, hz_cust_accounts hca, hz_parties hp, hz_cust_site_uses_all hcs, pa_projects_all pa, ra_customer_trx_lines_all ctl, zx_lines zl WHERE rc.org_id = ct.org_id AND ctl.customer_trx_id = ct.customer_trx_id AND ctl.org_id = ct.org_id AND rc.cust_trx_type_id = ct.cust_trx_type_id AND ct.customer_trx_id = gd.customer_trx_id and ctl.tax_line_id = zl.tax_line_id AND 'REC' = gd.account_class AND 'Y' = gd.latest_rec_flag AND ct.cust_trx_type_id = ctt.cust_trx_type_id AND ctt.type <> 'BR' AND ctt.org_id = ct.org_id AND ct.bill_to_customer_id = hca.cust_account_id AND hca.party_id = hp.party_id AND ct.bill_to_site_use_id = hcs.site_use_id AND ct.org_id = pa.org_id(+) AND ct.attribute3 = pa.segment1(+);