Search This Blog

Thursday 24 May 2012

Order Status / Delivery / Trip / Site

SELECT DISTINCT hcsu.LOCATION,
                a.ship_to_org_id,
                a.header_id,
                a.order_number,
                a.flow_status_code,
                a.cust_po_number,
                a.orig_sys_document_ref,
                a.attribute8 customer,
                a.creation_date,
                d.delivery_id,
                d.attribute13,
                b.released_status,
                wtv.trip_id,
                a.flow_status_code header_flow_status_code,
                d.last_update_date
FROM            oe_order_headers_all a,
                wsh_delivery_details b,
                wsh_delivery_assignments c,
                wsh_new_deliveries d,
                wsh_trips wtv,
                wsh_trip_stops pickup_stop,
                wsh_delivery_legs dl,
                hz_cust_accounts hca,
                hz_cust_acct_sites_all hcs,
                hz_cust_site_uses_all hcsu
WHERE           1 = 1
AND             hca.cust_account_id = hcs.cust_account_id
AND             a.header_id = b.source_header_id
AND             hcsu.site_use_id = a.ship_to_org_id
AND             hcs.cust_acct_site_id = hcsu.cust_acct_site_id
AND             hcsu.site_use_code = 'SHIP_TO'
AND             hcsu.status = 'A'
AND             a.header_id = b.source_header_id
AND             b.delivery_detail_id = c.delivery_detail_id
AND             c.delivery_id = d.delivery_id
AND             pickup_stop.stop_id = dl.pick_up_stop_id
AND             pickup_stop.trip_id = wtv.trip_id
AND             d.delivery_id = dl.delivery_id;

No comments:

Post a Comment