将旧的SQL语言更改为新的

时间:2015-11-09 11:35:32

标签: sql oracle oracle11g oracle10g

我目前是一名试图开发我的SQL的实习生。有人可以帮助我将旧语言改为新语言(orale 11g或sql 2014)下面是一个我正在改变的例子;

select apa.invoicE_num ap_invoice_num
, apa.creation_date
,  rat.TRX_NUMBER ar_trx_number
, rat.creation_date loaded_into_ar
,asw.inserted_date
, decode(pvs.org_id,86,'SP',87,'SV')
, pv.vendor_nam
,pv.segment1,
pvs.vendor_site_code
, asw.attribute6
, asw.invoice_amount
, asw.INVOICE_NUM

from asw.asw_ap_invoices_interface_aud asw
, ra_customer_trx_all rat
, po_vendor_sites_all pvs
, po_vendors pv
, ap_invoices_all apa

where asw.invoice_num = rat.trx_number (+)
and asw.VENDOR_SITE_ID = pvs.vendor_site_id
and pvs.vendor_id = pv.vendor_id
and asw.invoice_num = apa.invoicE_num (+)
and asw.invoice_amount = apa.invoicE_amount (+)
and asw.vendor_site_id = apa.vendor_site_id (+)
and asw.attribute_category = 'Retek Import'
and asw.attribute6 in ('MB','DA','RM','SB')
and trunc(inserted_date) > '29-OCT-2015'

感谢您阅读本文,希望您能提供帮助!

1 个答案:

答案 0 :(得分:2)

SELECT *
FROM a, b
WHERE a.id=b.id(+)

相同
SELECT *
FROM a LEFT OUTER JOIN b ON a.id=b.id

所以在你的情况下:

select apa.invoicE_num ap_invoice_num
, apa.creation_date
,  rat.TRX_NUMBER ar_trx_number
, rat.creation_date loaded_into_ar
,asw.inserted_date
, decode(pvs.org_id,86,'SP',87,'SV')
, pv.vendor_nam
,pv.segment1,
pvs.vendor_site_code
, asw.attribute6
, asw.invoice_amount
, asw.INVOICE_NUM

from asw.asw_ap_invoices_interface_aud asw
left outer join ra_customer_trx_all rat on asw.invoice_num = rat.trx_number
inner join po_vendor_sites_all on pvs asw.VENDOR_SITE_ID = pvs.vendor_site_id
inner join po_vendors pv on pvs.vendor_id = pv.vendor_id
left outer join ap_invoices_all apa on asw.invoice_amount = apa.invoicE_amount and asw.vendor_site_id = apa.vendor_site_id

where asw.attribute_category = 'Retek Import'
and asw.attribute6 in ('MB','DA','RM','SB')
and trunc(inserted_date) > '29-OCT-2015'