SELECT oha.order_number, oha.ordered_date,wdd.delivery_detail_id, wnd.delivery_id, wt.trip_id
,wdd.batch_id move_order#, customer.party_name, customer.account_number
,hp_ship.party_name ship_party_name
,hps_ship.party_site_name ship_party_site_name
, 'Ship to site use id - '
|| hcs_ship.site_use_id
|| '; '
|| hl_ship.address1
|| ','
|| hl_ship.city
|| ','
|| NVL (hl_ship.state, hl_ship.province)
|| ' '
|| hl_ship.postal_code ship_to_info
,bill_to.bill_to_info, bill_to.party_site_name bill_party_site_name
,bill_to.party_name bill_party_name
FROM ont.oe_order_headers_all oha
,ont.oe_order_lines_all ool
,wsh.wsh_delivery_details wdd
,wsh.wsh_delivery_assignments wda
,wsh.wsh_new_deliveries wnd
,wsh.wsh_delivery_legs wdl
,wsh.wsh_trip_stops wts
,wsh.wsh_trips wt
,ar.hz_cust_site_uses_all hcs_ship
,ar.hz_cust_acct_sites_all hca_ship
,ar.hz_party_sites hps_ship
,ar.hz_locations hl_ship
,ar.hz_parties hp_ship
,apps.hz_cust_accounts ac
, (SELECT 'Bill to site use id - '
|| hcs_bill.site_use_id
|| '; '
|| hl_bill.address1
|| ','
|| hl_bill.city
|| ','
|| NVL (hl_bill.state, hl_bill.province)
|| ' '
|| hl_bill.postal_code bill_to_info
,hcs_bill.site_use_id, hps_bill.party_site_name
,hp_bill.party_name
FROM ar.hz_cust_site_uses_all hcs_bill
,ar.hz_cust_acct_sites_all hca_bill
,ar.hz_party_sites hps_bill
,ar.hz_locations hl_bill
,ar.hz_parties hp_bill
,apps.hz_cust_accounts ac
WHERE hcs_bill.cust_acct_site_id = hca_bill.cust_acct_site_id
AND hca_bill.party_site_id = hps_bill.party_site_id
AND hps_bill.location_id = hl_bill.location_id
AND hp_bill.party_id = hps_bill.party_id
AND ac.cust_account_id = hca_bill.cust_account_id) bill_to
, (SELECT hp.party_name, ac.cust_account_id, ac.account_number
FROM ar.hz_parties hp, apps.hz_cust_accounts ac
WHERE ac.party_id = hp.party_id) customer
WHERE oha.ship_to_org_id = hcs_ship.site_use_id
AND hcs_ship.cust_acct_site_id = hca_ship.cust_acct_site_id
AND hca_ship.party_site_id = hps_ship.party_site_id
AND hps_ship.location_id = hl_ship.location_id
AND hp_ship.party_id = hps_ship.party_id
AND ac.cust_account_id = hca_ship.cust_account_id
AND oha.order_number = 4736862
AND oha.invoice_to_org_id = bill_to.site_use_id
AND customer.cust_account_id = oha.sold_to_org_id
AND oha.ordered_date > SYSDATE - 300
AND oha.header_id <= 4788667
AND oha.header_id > 4785400
AND oha.header_id = ool.header_id
AND wdd.source_header_id = oha.header_id
AND wdd.delivery_detail_id = wda.delivery_detail_id
AND wda.delivery_id = wnd.delivery_id
AND wnd.delivery_id = wdl.delivery_id
AND wdl.pick_up_stop_id = wts.stop_id
AND wts.trip_id = wt.trip_id
AND wdd.batch_id IS NOT NULL
,wdd.batch_id move_order#, customer.party_name, customer.account_number
,hp_ship.party_name ship_party_name
,hps_ship.party_site_name ship_party_site_name
, 'Ship to site use id - '
|| hcs_ship.site_use_id
|| '; '
|| hl_ship.address1
|| ','
|| hl_ship.city
|| ','
|| NVL (hl_ship.state, hl_ship.province)
|| ' '
|| hl_ship.postal_code ship_to_info
,bill_to.bill_to_info, bill_to.party_site_name bill_party_site_name
,bill_to.party_name bill_party_name
FROM ont.oe_order_headers_all oha
,ont.oe_order_lines_all ool
,wsh.wsh_delivery_details wdd
,wsh.wsh_delivery_assignments wda
,wsh.wsh_new_deliveries wnd
,wsh.wsh_delivery_legs wdl
,wsh.wsh_trip_stops wts
,wsh.wsh_trips wt
,ar.hz_cust_site_uses_all hcs_ship
,ar.hz_cust_acct_sites_all hca_ship
,ar.hz_party_sites hps_ship
,ar.hz_locations hl_ship
,ar.hz_parties hp_ship
,apps.hz_cust_accounts ac
, (SELECT 'Bill to site use id - '
|| hcs_bill.site_use_id
|| '; '
|| hl_bill.address1
|| ','
|| hl_bill.city
|| ','
|| NVL (hl_bill.state, hl_bill.province)
|| ' '
|| hl_bill.postal_code bill_to_info
,hcs_bill.site_use_id, hps_bill.party_site_name
,hp_bill.party_name
FROM ar.hz_cust_site_uses_all hcs_bill
,ar.hz_cust_acct_sites_all hca_bill
,ar.hz_party_sites hps_bill
,ar.hz_locations hl_bill
,ar.hz_parties hp_bill
,apps.hz_cust_accounts ac
WHERE hcs_bill.cust_acct_site_id = hca_bill.cust_acct_site_id
AND hca_bill.party_site_id = hps_bill.party_site_id
AND hps_bill.location_id = hl_bill.location_id
AND hp_bill.party_id = hps_bill.party_id
AND ac.cust_account_id = hca_bill.cust_account_id) bill_to
, (SELECT hp.party_name, ac.cust_account_id, ac.account_number
FROM ar.hz_parties hp, apps.hz_cust_accounts ac
WHERE ac.party_id = hp.party_id) customer
WHERE oha.ship_to_org_id = hcs_ship.site_use_id
AND hcs_ship.cust_acct_site_id = hca_ship.cust_acct_site_id
AND hca_ship.party_site_id = hps_ship.party_site_id
AND hps_ship.location_id = hl_ship.location_id
AND hp_ship.party_id = hps_ship.party_id
AND ac.cust_account_id = hca_ship.cust_account_id
AND oha.order_number = 4736862
AND oha.invoice_to_org_id = bill_to.site_use_id
AND customer.cust_account_id = oha.sold_to_org_id
AND oha.ordered_date > SYSDATE - 300
AND oha.header_id <= 4788667
AND oha.header_id > 4785400
AND oha.header_id = ool.header_id
AND wdd.source_header_id = oha.header_id
AND wdd.delivery_detail_id = wda.delivery_detail_id
AND wda.delivery_id = wnd.delivery_id
AND wnd.delivery_id = wdl.delivery_id
AND wdl.pick_up_stop_id = wts.stop_id
AND wts.trip_id = wt.trip_id
AND wdd.batch_id IS NOT NULL
No comments:
Post a Comment