Original query:

explain analyze SELECT wrE41."bol_nbr" as c0,wrE41."load_nbr" as c1,wrE17."ship_via_code" as c2,wrE17."oh_order_nbr" as c3,wrE17."oh_customer_po_nbr" as c4,wrE49."name" as c5,wrE49."address_1" as c6,wrE49."address_2" as c7,wrE17."oh_shipto_addr2" as c8,wrE41."cust_field_10" as c9,wrE17."hdr_cust_short_text_5" as c10,wrE17."oh_cust_field_3" as c11,wrE41."cust_field_3" as c12,wrE41."trailer_nbr" as c13,wrE41."cust_field_1" as c14,wrE41."cust_field_2" as c15,wrE41."cust_field_9" as c16,wrE17."hdr_cust_short_text_4" as c17,wrE41."last_load_ts_date" as c18,wrE14."batch_number" as c19,wrE49."code" as c20,wrE17."oh_shipto_name" as c21,wrE17."oh_shipto_addr" as c22,wrE49."address_3" as c23,wrE49."city" as c24,wrE17."oh_shipto_addr3" as c25,wrE17."oh_shipto_city" as c26,wrE49."state" as c27,wrE17."oh_shipto_state" as c28,wrE49."zip" as c29,wrE17."oh_shipto_zip" as c30,wrE30."un_number" as c31,wrE18."packed_qty" as c32,wrE30."external_style" as c33,wrE41."cust_field_6" as c34,wrE30."un_description" as c35,wrE30."description" as c36,wrE41."cust_field_8" as c37,wrE41."cust_field_7" as c38,wrE41."cust_field_5" as c39,wrE41."facility_id" as c40,wrE9."facility_company_xref_id" as c41,wrE9."container_nbr" as c42,wrE9."type" as c43,wrE42."dtl_id" as c44,wrE18."id" as c45,wrE17."od_seq_nbr" as c46,wrE14."id" as c47,wrE49."facility_type_id" as c48,wrE50."code" as c49,wrE50."company_type_id" as c50,wrE30."company_id" as c51,wrE30."part_a" as c52,wrE30."part_b" as c53,wrE30."part_c" as c54,wrE30."part_d" as c55,wrE30."part_e" as c56,wrE30."part_f" as c57,wrE42."dtl_container_id" as c58,wrE9."id" as c59,wrE42."hdr_load_id" as c60,wrE41."id" as c61,wrE49."id" as c62,wrE41."company_id" as c63,wrE50."id" as c64,wrE18."order_dtl_id" as c65,wrE17."id" as c66,wrE18."to_inventory_id" as c67,wrE17."od_item_id" as c68,wrE30."id" as c69,wrE14."container_id" as c70,wrE17."dtl_cust_short_text_2" as c71
	FROM (Select hdr.bol_nbr as hdr_bol_nbr,hdr.create_ts as hdr_create_ts,hdr.id as hdr_id,hdr.load_id as hdr_load_id,hdr.mod_ts as hdr_mod_ts,hdr.mod_user as hdr_mod_user,hdr.seq_nbr as hdr_seq_nbr,hdr.shipto_addr as hdr_shipto_addr,hdr.shipto_facility_id as hdr_shipto_facility_id,hdr.shipto_name as hdr_shipto_name,hdr.stage_location_id as hdr_stage_location_id,hdr.status_id as hdr_status_id,hdr.total_shipping_charge as hdr_total_shipping_charge,hdr.total_volume as hdr_total_volume,hdr.total_weight as hdr_total_weight ,dtl.bol_nbr as dtl_bol_nbr,dtl.container_id as dtl_container_id,dtl.create_ts as dtl_create_ts,dtl.id as dtl_id,dtl.mod_ts as dtl_mod_ts,dtl.mod_user as dtl_mod_user,dtl.ob_stop_id as dtl_ob_stop_id ,stop_status.description as hdr_status,date(hdr.create_ts) as hdr_create_ts_date,extract(week from date(hdr.create_ts)) as hdr_create_ts_week, date_trunc('hour', hdr.create_ts) as hdr_create_ts_dthr,date(hdr.mod_ts) as hdr_mod_ts_date,extract(week from date(hdr.mod_ts)) as hdr_mod_ts_week,date_trunc('hour', hdr.mod_ts) as hdr_mod_ts_dthr,date(dtl.create_ts) as dtl_create_ts_date,extract(week from date(dtl.create_ts)) as dtl_create_ts_week, date_trunc('hour', dtl.create_ts) as dtl_create_ts_dthr,date(dtl.mod_ts) as dtl_mod_ts_date,extract(week from date(dtl.mod_ts)) as dtl_mod_ts_week, date_trunc('hour', dtl.mod_ts) as dtl_mod_ts_dthr ,fac.code as hdr_shipto_facility_code, fac.name as hdr_shipto_fac_name, fac.address_1 as hdr_shipto_fac_addr_1, fac.address_2 as hdr_shipto_fac_addr_2, fac.locality as hdr_shipto_fac_locality, fac.city as hdr_shipto_fac_city, fac.state as hdr_shipto_fac_state, fac.zip as hdr_shipto_fac_zip from ob_stop_dtl dtl inner join ob_stop hdr on dtl.ob_stop_id = hdr.id inner join stop_status on hdr.status_id = stop_status.id inner join container ctr on dtl.container_id = ctr.id left outer join facility fac on hdr.shipto_facility_id = fac.id where ctr.facility_company_xref_id in (280)) wrE42  inner join (select ctr.asset_id, ctr.asset_seal_nbr, ctr.audit_status_id, ctr.cart_posn_nbr, ctr.container_nbr, ctr.create_ts, ctr.curr_location_id, ctr.facility_company_xref_id, ctr.first_putaway_ts, ctr.id, ctr.lpn_type_id, ctr.mod_ts, ctr.mod_user, ctr.pack_user, ctr.pallet_id, ctr.parcel_batch_flg, ctr.pick_user, ctr.prev_location_id, ctr.price_labels_printed, ctr.priority_date, ctr.putawaytype_id, ctr.qc_status_id, ctr.rcvd_shipment_id, ctr.rcvd_ts, ctr.rcvd_user, ctr.ref_iblpn_nbr, ctr.ref_oblpn_nbr, ctr.ref_po_nbr, ctr.ref_shipment_nbr, ctr.status_id, ctr.type, ctr.vas_status_id, ctr.volume, ctr.weight, cs.description as status, ltype.code as lpn_type, ltype.description as lpn_type_description, (case when ctr.curr_location_id is not null then ctr.curr_location_id when plt.curr_location_id is not null then plt.curr_location_id else null end) as container_curr_location_id, (case when ctr.prev_location_id is not null then ctr.prev_location_id when plt.prev_location_id is not null then plt.prev_location_id else null end) as container_prev_location_id, plt.pallet_nbr, plt.is_lpn_flg as pallet_is_lpn, ps.description as pallet_status, aus.description as pallet_audit_status, fac.id as facility_id, fac.code as facility_code, comp.id as company_id, comp.code as company_code, date(ctr.create_ts) as create_ts_date, extract(week from date(ctr.create_ts)) as create_ts_week, date_trunc('hour', ctr.create_ts) as create_ts_dthr, date(ctr.mod_ts) as mod_ts_date, date(ctr.mod_ts at time zone 'US/Central') as mod_ts_date_fac_tz, extract(week from date(ctr.mod_ts)) as mod_ts_week, date_trunc('hour', ctr.mod_ts) as mod_ts_dthr, date_trunc('hour', ctr.mod_ts at time zone 'US/Central') as mod_ts_dthr_fac_tz, ctr.actual_weight_flg, ctr.comments, ltype.max_volume, ltype.max_weight, ltype.empty_weight, ltype.length as lpntype_length, ltype.width as lpntype_width,ltype.height as lpntype_height, ltype.use_for_cubing_flg, ctr.length as container_length, ctr.width as container_width, ctr.height as container_height from container ctr inner join container_status cs on ctr.status_id = cs.id inner join facility_company_xref fcx on ctr.facility_company_xref_id = fcx.id inner join facility fac on fcx.facility_id = fac.id inner join company comp on fcx.company_id = comp.id left outer join lpn_type ltype on ctr.lpn_type_id = ltype.id left outer join pallet plt on ctr.pallet_id = plt.id left outer join pallet_status ps on plt.status_id = ps.id left outer join audit_status aus on plt.audit_status_id = aus.id where ctr.facility_company_xref_id in (280)) wrE9  on (wrE42."dtl_container_id" = wrE9."id") inner join (Select load.bol_nbr, load.carrier_id, load.company_id, load.create_ts, load.driver, load.est_departure_ts, load.facility_id, load.first_gdr_nbr, load.first_load_ts, load.freight_class, load.id, load.last_load_ts, load.load_nbr, load.mod_ts, load.mod_user, load.pro_nbr, load.route_nbr, load.sched_delivery_ts, load.seal_nbr, load.status_id, load.total_shipping_charge, load.total_volume, load.total_weight, tr.trailer_nbr, load.trailer_type_id, load.type, comp.code as company_code, fac.code as facility_code, ls.description as status, carr.code as carrier_code, carr.description as carrier_description, carr_type.description as carrier_type, date(load.create_ts) as create_ts_date, extract(week from date(load.create_ts)) as create_ts_week, date_trunc('hour', load.create_ts) as create_ts_dthr, date(load.mod_ts) as mod_ts_date, date(load.mod_ts at time zone 'US/Central') as mod_ts_date_fac_tz, extract(week from date(load.mod_ts)) as mod_ts_week, date_trunc('hour', load.mod_ts) as mod_ts_dthr, date_trunc('hour', load.mod_ts at time zone 'US/Central') as mod_ts_dthr_fac_tz, date(load.first_load_ts) as first_load_ts_date, date_trunc('hour', load.first_load_ts) as first_load_ts_dthr, extract(week from date(load.first_load_ts)) as first_load_ts_week, date(load.last_load_ts) as last_load_ts_date, date_trunc('hour', load.last_load_ts) as last_load_ts_dthr, extract(week from date(load.last_load_ts)) as last_load_ts_week, load.cust_field_1, load.cust_field_2, load.cust_field_3, load.cust_field_4, load.cust_field_5, load.cust_field_6, load.cust_field_7, load.cust_field_8, load.cust_field_9, load.cust_field_10, load.trailer_id as trailer_id from load inner join company comp on load.company_id = comp.id inner join facility fac on load.facility_id = fac.id inner join load_status ls on load.status_id = ls.id left outer join carrier carr on load.carrier_id = carr.id left outer join carrier_type carr_type on carr.carrier_type_id = carr_type.id left outer join trailer tr on load.trailer_id = tr.id where load.facility_id in (4) and load.company_id in (199) and load.type = 'O' ) wrE41  on (wrE42."hdr_load_id" = wrE41."id") inner join (Select fac.address_1 as address_1,fac.address_2 as address_2,fac.address_3 as address_3,fac.bonus_amt_per_user as bonus_amt_per_user,fac.city as city,fac.code as code,fac.contact as contact,fac.country as country,fac.create_ts as create_ts,fac.cust_field_1 as cust_field_1,fac.cust_field_2 as cust_field_2,fac.cust_field_3 as cust_field_3,fac.cust_field_4 as cust_field_4,fac.cust_field_5 as cust_field_5,fac.default_ship_via_code as default_ship_via_code,fac.email as email,fac.facility_type_id as facility_type_id,fac.id as id,fac.lang as lang,fac.locality as locality,fac.mod_ts as mod_ts,fac.mod_user as mod_user,fac.name as name,fac.parent_company_id as parent_company_id,fac.phone_nbr as phone_nbr,fac.priority as priority,fac.state as state,fac.time_zone_id as time_zone_id,fac.zip as zip from facility fac where id in (4)) wrE49  on (wrE41."facility_id" = wrE49."id") inner join (Select comp.active_flg as active_flg,comp.address_1 as address_1,comp.address_2 as address_2,comp.address_3 as address_3,comp.city as city,comp.code as code,comp.company_type_id as company_type_id,comp.contact as contact,comp.country as country,comp.create_ts as create_ts,comp.cust_field_1 as cust_field_1,comp.cust_field_2 as cust_field_2,comp.cust_field_3 as cust_field_3,comp.cust_field_4 as cust_field_4,comp.cust_field_5 as cust_field_5,comp.custom_db_name as custom_db_name,comp.edi_partner_nbr as edi_partner_nbr,comp.email as email,comp.id as id,comp.locality as locality,comp.mod_ts as mod_ts,comp.mod_user as mod_user,comp.name as name,comp.parent_company_id as parent_company_id,comp.phone_nbr as phone_nbr,comp.state as state,comp.univ_id_1 as univ_id_1,comp.zip as zip from company comp where id in (199)) wrE50  on (wrE41."company_id" = wrE50."id") inner join (Select inv.batch_number_id as batch_number_id,inv.case_qty as case_qty,inv.container_id as container_id,inv.create_ts as create_ts,inv.curr_qty as curr_qty,inv.expiry_date as expiry_date,inv.facility_id as facility_id,inv.id as id,invn_attr.invn_attr_a as invn_attr_a,invn_attr.invn_attr_b as invn_attr_b,invn_attr.invn_attr_c as invn_attr_c, invn_attr.invn_attr_d as invn_attr_d,invn_attr.invn_attr_e as invn_attr_e,invn_attr.invn_attr_f as invn_attr_f,invn_attr.invn_attr_g as invn_attr_g, invn_attr.invn_attr_h as invn_attr_h,invn_attr.invn_attr_i as invn_attr_i,invn_attr.invn_attr_j as invn_attr_j,invn_attr.invn_attr_k as invn_attr_k, invn_attr.invn_attr_l as invn_attr_l,invn_attr.invn_attr_m as invn_attr_m,invn_attr.invn_attr_n as invn_attr_n,invn_attr.invn_attr_o as invn_attr_o, inv.item_id as item_id,inv.location_id as location_id,inv.manufacture_date as manufacture_date,inv.mod_ts as mod_ts,inv.mod_user as mod_user,inv.orig_qty as orig_qty,inv.pack_qty as pack_qty,inv.priority_date as priority_date,inv.status_id as status_id,fac.code as facility_code,inv_st.description as status,bn.batch_nbr as batch_number, bn.expiry_date as batch_expiry_date, date(inv.create_ts) as create_ts_date,extract(week from date(inv.create_ts)) as create_ts_week, date_trunc('hour', inv.create_ts) as create_ts_dthr,date(inv.mod_ts) as mod_ts_date,extract(week from date(inv.mod_ts)) as mod_ts_week, date_trunc('hour', inv.mod_ts) as mod_ts_dthr from inventory inv inner join inventory_attribute invn_attr on invn_attr.id = inv.invn_attr_id inner join facility fac on inv.facility_id = fac.id inner join inventory_status inv_st on inv.status_id = inv_st.id left outer join batch_number bn on inv.batch_number_id = bn.id where inv.facility_id in (4)) wrE14  on (wrE9."id" = wrE14."container_id") inner join (Select al.alloc_qty, al.alloc_uom_id, al.cartonize_uom_id, al.create_ts, al.from_inventory_id, al.id, al.mhe_system_id, al.mod_ts, al.mod_user, al.ob_lpn_type_id, al.order_dtl_id, al.packed_qty, al.picked_ts as picked_time, al.pick_user, al.status_id, al.task_id, al.task_seq_nbr, al.to_inventory_id, al.type_id, al.wave_id, u1.uom_name as alloc_uom, u2.uom_name as cartonize_uom, arh.run_nbr as wave_number, astat.description as status, atype.type_name as allocation_type, ltype.description as ob_lpn_type_code, ltype.description as ob_lpn_type_description, date(al.create_ts) as create_ts_date, extract(week from date(al.create_ts)) as create_ts_week, date_trunc('hour', al.create_ts) as create_ts_dthr, date(al.mod_ts) as mod_ts_date, date(al.mod_ts at time zone 'US/Central') as mod_ts_date_fac_tz, extract(week from date(al.mod_ts)) as mod_ts_week, date_trunc('hour', al.mod_ts) as mod_ts_dthr, date_trunc('hour', al.mod_ts at time zone 'US/Central') as mod_ts_dthr_fac_tz, arh.alloc_mode_description, arh.wave_template_name, tc.description as task_creation from allocation al inner join allocation_status astat on al.status_id = astat.id inner join allocation_type atype on al.type_id = atype.id left outer join allocation_run_hdr arh on al.wave_id = arh.id left outer join uom u1 on al.alloc_uom_id = u1.id left outer join uom u2 on al.cartonize_uom_id = u2.id left outer join lpn_type ltype on al.ob_lpn_type_id = ltype.id left outer join task_creation tc on arh.task_creation_id = tc.id where (arh.facility_id in (4) or arh.facility_id is null)) wrE18  on (wrE14."id" = wrE18."to_inventory_id") inner join (Select od.id as id, oh.carrier_account_nbr as oh_carrier_account_nbr,oh.create_ts as oh_create_ts,oh.currency_code as oh_currency_code,oh.cust_addr as oh_cust_addr,oh.cust_addr2 as oh_cust_addr2,oh.cust_addr3 as oh_cust_addr3,oh.cust_city as oh_cust_city,oh.cust_contact as oh_cust_contact,oh.cust_country as oh_cust_country,oh.cust_email as oh_cust_email,oh.cust_field_1 as oh_cust_field_1,oh.cust_field_2 as oh_cust_field_2,oh.cust_field_3 as oh_cust_field_3,oh.cust_field_4 as oh_cust_field_4,oh.cust_field_5 as oh_cust_field_5,oh.cust_name as oh_cust_name,oh.cust_nbr as oh_cust_nbr,oh.customer_po_nbr as oh_customer_po_nbr,oh.cust_phone_nbr as oh_cust_phone_nbr,oh.cust_state as oh_cust_state,oh.cust_zip as oh_cust_zip,oh.dest_dept_nbr as oh_dest_dept_nbr,oh.dest_facility_id as oh_dest_facility_id,oh.destination_company_id as oh_destination_company_id,oh.exp_date as oh_exp_date,oh.external_route as oh_external_route,oh.facility_company_xref_id as oh_facility_company_xref_id,oh.host_allocation_nbr as oh_host_allocation_nbr,oh.id as oh_id,oh.mod_ts as oh_mod_ts,oh.mod_user as oh_mod_user,oh.ob_lpn_type as oh_ob_lpn_type,oh.ob_lpn_type_id as oh_ob_lpn_type_id,oh.ord_date as oh_ord_date,oh.order_nbr as oh_order_nbr,oh.order_type_id as oh_order_type_id,oh.payment_method_id as oh_payment_method_id,oh.priority as oh_priority,oh.record_origin_code as oh_record_origin_code,oh.ref_nbr as oh_ref_nbr,oh.req_ship_date as oh_req_ship_date,oh.route_nbr as oh_route_nbr,oh.sales_channel as oh_sales_channel,oh.sales_order_nbr as oh_sales_order_nbr,oh.shipto_addr as oh_shipto_addr,oh.shipto_addr2 as oh_shipto_addr2,oh.shipto_addr3 as oh_shipto_addr3,oh.shipto_city as oh_shipto_city,oh.shipto_contact as oh_shipto_contact,oh.shipto_country as oh_shipto_country,oh.shipto_email as oh_shipto_email,oh.shipto_facility_id as oh_shipto_facility_id,oh.shipto_name as oh_shipto_name,oh.shipto_phone_nbr as oh_shipto_phone_nbr,oh.shipto_state as oh_shipto_state,oh.shipto_zip as oh_shipto_zip,oh.ship_via_id as oh_ship_via_id,oh.ship_via_ref_code as oh_ship_via_ref_code,oh.spl_instr as oh_spl_instr,oh.stage_location_id as oh_stage_location_id,oh.start_ship_date as oh_start_ship_date,oh.status_id as oh_status_id,oh.stop_ship_date as oh_stop_ship_date,oh.vas_group_code as oh_vas_group_code, oh.gift_msg as hdr_gift_msg, oh.sched_ship_date as hdr_sched_ship_date, oh.customer_po_type as hdr_customer_po_type, oh.customer_vendor_code as hdr_customer_vendor_code, oh.cust_date_1 as hdr_cust_date_1, oh.cust_date_2 as hdr_cust_date_2, oh.cust_date_3 as hdr_cust_date_3, oh.cust_date_4 as hdr_cust_date_4, oh.cust_date_5 as hdr_cust_date_5, oh.cust_number_1 as hdr_cust_number_1, oh.cust_number_2 as hdr_cust_number_2, oh.cust_number_3 as hdr_cust_number_3, oh.cust_number_4 as hdr_cust_number_4, oh.cust_number_5 as hdr_cust_number_5, oh.cust_decimal_1 as hdr_cust_decimal_1, oh.cust_decimal_2 as hdr_cust_decimal_2, oh.cust_decimal_3 as hdr_cust_decimal_3, oh.cust_decimal_4 as hdr_cust_decimal_4, oh.cust_decimal_5 as hdr_cust_decimal_5, oh.cust_short_text_1 as hdr_cust_short_text_1, oh.cust_short_text_2 as hdr_cust_short_text_2, oh.cust_short_text_4 as hdr_cust_short_text_4, oh.cust_short_text_5 as hdr_cust_short_text_5, oh.cust_short_text_6 as hdr_cust_short_text_6, oh.cust_short_text_7 as hdr_cust_short_text_7, oh.cust_short_text_8 as hdr_cust_short_text_8, oh.cust_short_text_9 as hdr_cust_short_text_9, oh.cust_short_text_10 as hdr_cust_short_text_10, oh.cust_short_text_11 as hdr_cust_short_text_11, oh.cust_short_text_12 as hdr_cust_short_text_12, oh.cust_long_text_1 as hdr_cust_long_text_1, oh.cust_long_text_2 as hdr_cust_long_text_2, oh.cust_long_text_3 as hdr_cust_long_text_3, oh.create_user as hdr_create_user, oh.order_nbr_to_replace, oh.stop_ship_flg ,od.alloc_qty as od_alloc_qty,od.batch_number_id as od_batch_number_id,od.cost as od_cost,od.create_ts as od_create_ts,od.cust_field_1 as od_cust_field_1,od.cust_field_2 as od_cust_field_2,od.cust_field_3 as od_cust_field_3,od.cust_field_4 as od_cust_field_4,od.cust_field_5 as od_cust_field_5,od.dest_facility_attr_a as od_dest_facility_attr_a,od.dest_facility_attr_b as od_dest_facility_attr_b,od.dest_facility_attr_c as od_dest_facility_attr_c,od.host_ob_lpn_nbr as od_host_ob_lpn_nbr,od.id as od_id,invn_attr.invn_attr_a as od_invn_attr_a,invn_attr.invn_attr_b as od_invn_attr_b,invn_attr.invn_attr_c as od_invn_attr_c,invn_attr.invn_attr_d as od_invn_attr_d,invn_attr.invn_attr_e as od_invn_attr_e,invn_attr.invn_attr_f as od_invn_attr_f,invn_attr.invn_attr_g as od_invn_attr_g,invn_attr.invn_attr_h as od_invn_attr_h,invn_attr.invn_attr_i as od_invn_attr_i,invn_attr.invn_attr_j as od_invn_attr_j,invn_attr.invn_attr_k as od_invn_attr_k,invn_attr.invn_attr_l as od_invn_attr_l,invn_attr.invn_attr_m as od_invn_attr_m,invn_attr.invn_attr_n as od_invn_attr_n,invn_attr.invn_attr_o as od_invn_attr_o,od.item_id as od_item_id,od.mod_ts as od_mod_ts,od.mod_user as od_mod_user,od.order_id as od_order_id,od.ord_qty as od_ord_qty,od.orig_ord_qty as od_orig_ord_qty,od.po_nbr as od_po_nbr,od.ref_nbr_1 as od_ref_nbr_1,od.req_cntr_nbr as od_req_cntr_nbr,od.sale_price as od_sale_price,od.seq_nbr as od_seq_nbr,od.shipment_nbr as od_shipment_nbr,od.spl_instr as od_spl_instr,od.vas_activity_code as od_vas_activity_code, od.serial_nbr as dtl_serial_nbr, od.voucher_nbr as dtl_voucher_nbr, od.voucher_amount as dtl_voucher_amount, od.voucher_exp_date as dtl_voucher_exp_date, od.req_pallet_nbr as dtl_req_pallet_nbr, od.lock_code as dtl_lock_code, od.cust_date_1 as dtl_cust_date_1, od.cust_date_2 as dtl_cust_date_2, od.cust_date_3 as dtl_cust_date_3, od.cust_date_4 as dtl_cust_date_4, od.cust_date_5 as dtl_cust_date_5, od.cust_number_1 as dtl_cust_number_1, od.cust_number_2 as dtl_cust_number_2, od.cust_number_3 as dtl_cust_number_3, od.cust_number_4 as dtl_cust_number_4, od.cust_number_5 as dtl_cust_number_5, od.cust_decimal_1 as dtl_cust_decimal_1, od.cust_decimal_2 as dtl_cust_decimal_2, od.cust_decimal_3 as dtl_cust_decimal_3, od.cust_decimal_4 as dtl_cust_decimal_4, od.cust_decimal_5 as dtl_cust_decimal_5, od.cust_short_text_1 as dtl_cust_short_text_1, od.cust_short_text_2 as dtl_cust_short_text_2, od.cust_short_text_3 as dtl_cust_short_text_3, od.cust_short_text_4 as dtl_cust_short_text_4, od.cust_short_text_5 as dtl_cust_short_text_5, od.cust_short_text_6 as dtl_cust_short_text_6, od.cust_short_text_7 as dtl_cust_short_text_7, od.cust_short_text_8 as dtl_cust_short_text_8, od.cust_short_text_9 as dtl_cust_short_text_9, od.cust_short_text_10 as dtl_cust_short_text_10, od.cust_short_text_11 as dtl_cust_short_text_11, od.cust_short_text_12 as dtl_cust_short_text_12, od.cust_long_text_1 as dtl_cust_long_text_1, od.cust_long_text_2 as dtl_cust_long_text_2, od.cust_long_text_3 as dtl_cust_long_text_3, od.create_user as dtl_create_user ,os.description as oh_status,dest_co.code as oh_destination_company_code, ltype.description as oh_ob_lpn_type_descr, bn.batch_nbr as od_batch_nbr, sv.code as ship_via_code, sv.description as ship_via_description ,otype.order_type as order_type,otype.description as order_type_description,otype.dest_facility_flg as order_type_dest_facility_flg,otype.flowthrough_flg as order_type_flowthrough_flg,otype.only_deallocate_on_short_flg as order_type_only_deallocate_on_short_flg,otype.partial_allocation_flg as order_type_partial_allocation_flg,otype.wave_flg as order_type_wave_flg ,fac.id as oh_facility_id,fac.code as oh_facility_code, comp.id as oh_company_id, comp.code as oh_company_code,date(oh.create_ts) as oh_create_ts_date,extract(week from date(oh.create_ts)) as oh_create_ts_week,date_trunc('hour', oh.create_ts) as oh_create_ts_dthr,date(od.create_ts) as od_create_ts_date,extract(week from date(od.create_ts)) as od_create_ts_week,date_trunc('hour', od.create_ts) as od_create_ts_dthr,date(oh.mod_ts) as oh_mod_ts_date,extract(week from date(oh.mod_ts)) as oh_mod_ts_week,date_trunc('hour', oh.mod_ts) as oh_mod_ts_dthr,date(od.mod_ts) as od_mod_ts_date,extract(week from date(od.mod_ts)) as od_mod_ts_week,date_trunc('hour', od.mod_ts) as od_mod_ts_dthr, extract(week from date(oh.ord_date)) as oh_ord_date_week ,dest_fac.code as oh_dest_facility_code, dest_fac.name as oh_dest_fac_name, dest_fac.address_1 as oh_dest_fac_addr_1, dest_fac.address_2 as oh_dest_fac_addr_2, dest_fac.locality as oh_dest_fac_locality, dest_fac.city as oh_dest_fac_city, dest_fac.state as oh_dest_fac_state, dest_fac.zip as oh_dest_fac_zip ,shiptto_fac.code as oh_shipto_facility_code, shiptto_fac.name as oh_shipto_fac_name, shiptto_fac.address_1 as oh_shipto_fac_addr_1, shiptto_fac.address_2 as oh_shipto_fac_addr_2, shiptto_fac.locality as oh_shipto_fac_locality, shiptto_fac.city as oh_shipto_fac_city, shiptto_fac.state as oh_shipto_fac_state, shiptto_fac.zip as oh_shipto_fac_zip,od.orig_item_code as od_orig_item_code, oh.cust_short_text_3 as hdr_cust_short_text_3, oh.work_order_kit_id as oh_work_order_kit_id, oh.externally_planned_load_flg as oh_externally_planned_load_flg, oh.order_nbr_to_replace as oh_order_nbr_to_replace, oh.billto_carrier_account_nbr as oh_billto_carrier_account_nbr, oh.duties_carrier_account_nbr as oh_duties_carrier_account_nbr, oh.erp_source_hdr_ref as oh_erp_source_hdr_ref, oh.erp_source_system_ref as oh_erp_source_system_ref, oh.tms_order_hdr_ref as oh_tms_order_hdr_ref, oh.group_ref as oh_group_ref, od.unit_declared_value as od_unit_declared_value, od.externally_planned_load_nbr as od_externally_planned_load_nbr, od.erp_source_line_ref as od_erp_source_line_ref, od.erp_source_shipment_ref as od_erp_source_shipment_ref, od.erp_fulfillment_line_ref as od_erp_fulfillment_line_ref, od.sales_order_line_ref as od_sales_order_line_ref, od.sales_order_schedule_ref as od_sales_order_schedule_ref, od.tms_order_dtl_ref as od_tms_order_dtl_ref from order_dtl od inner join order_hdr oh on od.order_id = oh.id inner join inventory_attribute invn_attr on invn_attr.id = od.invn_attr_id inner join company dest_co on oh.destination_company_id = dest_co.id inner join order_status os on oh.status_id = os.id inner join order_type otype on oh.order_type_id = otype.id inner join facility_company_xref fcx on oh.facility_company_xref_id = fcx.id inner join facility fac on fcx.facility_id = fac.id inner join company comp on fcx.company_id = comp.id left outer join facility dest_fac on oh.dest_facility_id = dest_fac.id left outer join facility shiptto_fac on oh.shipto_facility_id = shiptto_fac.id left outer join lpn_type ltype on oh.ob_lpn_type_id = ltype.id left outer join batch_number bn on od.batch_number_id = bn.id left outer join ship_via sv on oh.ship_via_id = sv.id where oh.facility_company_xref_id in (280)) wrE17  on (wrE18."order_dtl_id" = wrE17."id") inner join (select item.id as id, item.company_id as company_id,company.code as company_code, item.description as description, item.barcode as barcode, item.unit_cost as unit_cost, item.unit_length as unit_length, item.unit_width as unit_width, item.unit_height as unit_height, item.unit_weight as unit_weight, item.unit_volume as unit_volume, item.hazmat as hazmat, item.part_b as part_b, item.part_c as part_c, item.part_d as part_d, item.part_e as part_e, item.part_f as part_f, item.part_a as part_a, item.calculated_code as item_code, item.external_style as external_style, item.vas_group_code as vas_group_code, item.pre_pack_code as pre_pack_code, item.item_alternate_code as item_alternate_code, item.host_aware_item_flg as host_aware_item_flg, item.short_descr as short_descr, putaway_type.pa_type as putaway_type, putaway_type.description as putaway_type_description, item.is_parent_flg as is_parent_flg, item.mod_interface_flg as mod_interface_flg, item.create_ts as create_ts, item.mod_ts as mod_ts, item.mod_user as mod_user, date(item.create_ts) as create_ts_date, date_trunc('hour', item.create_ts) as create_ts_dthr,extract(week from date(item.create_ts)) as create_ts_week, date(item.mod_ts) as mod_ts_date, date_trunc('hour', item.mod_ts) as mod_ts_dthr, extract(week from date(item.mod_ts)) as mod_ts_week,item.handle_decimal_qty_flg as handle_decimal_qty_flg ,item_characteristics.recv_type as recv_type, item_characteristics.catch_weight_method as catch_weight_method, item_characteristics.order_consolidation_attr as order_consolidation_attr, item_characteristics.season_code as season_code, item_characteristics.brand_code as brand_code, item_characteristics.cust_attr_1 as cust_attr_1, item_characteristics.cust_attr_2 as cust_attr_2, item_characteristics.stackability_code as stackability_code, item_characteristics.req_batch_nbr_flg as req_batch_nbr_flg, item_characteristics.serial_nbr_tracking_id as serial_nbr_tracking_id, mode.description as serial_nbr_tracking_description, item_characteristics.conveyable as conveyable, item_characteristics.sortable as sortable, item_characteristics.velocity_code as velocity_code, item_characteristics.regularity_code as regularity_code, lpn_type.code as ob_lpn_type_code, item_characteristics.full_oblpn_type as full_oblpn_type, item_characteristics.case_oblpn_type as case_oblpn_type, item_characteristics.pack_oblpn_type as pack_oblpn_type, item_characteristics.un_number as un_number, item_characteristics.un_class as un_class, item_characteristics.un_description as un_description, item_characteristics.packing_group as packing_group, item_characteristics.proper_shipping_name as proper_shipping_name, item_characteristics.excepted_qty_instr as excepted_qty_instr, item_characteristics.limited_qty_flg as limited_qty_flg, item_characteristics.fulldg_flg as fulldg_flg, item_characteristics.hazard_statement as hazard_statement, item_characteristics.shipping_temperature_instr as shipping_temperature_instr ,item_metrics.retail_price as retail_price, item_metrics.net_cost as unit_net_cost, item_metrics.currency_code as currency_code, item_metrics.std_pack_qty as std_pack_qty, item_metrics.std_pack_length as std_pack_length, item_metrics.std_pack_width as std_pack_width, item_metrics.std_pack_height as std_pack_height, item_metrics.std_pack_weight as std_pack_weight, item_metrics.std_pack_volume as std_pack_volume, item_metrics.std_case_qty as std_case_qty, item_metrics.max_case_qty as max_case_qty, item_metrics.std_case_length as std_case_length, item_metrics.std_case_width as std_case_width, item_metrics.std_case_height as std_case_height, item_metrics.std_case_weight as std_case_weight, item_metrics.std_case_volume as std_case_volume, item_metrics.dimension1 as dimension1, item_metrics.dimension2 as dimension2, item_metrics.dimension3 as dimension3, item_metrics.lpns_per_tier as lpns_per_tier, item_metrics.tiers_per_pallet as tiers_per_pallet, item_metrics.product_life as product_life, item_metrics.percent_acceptable_product_life as percent_acceptable_product_life ,hierarchy_1.code as hierarchy_1_code, hierarchy_1.description as hierarchy_1_description, hierarchy_2.code as hierarchy_2_code, hierarchy_2.description as hierarchy_2_description, hierarchy_3.code as hierarchy_3_code, hierarchy_3.description as hierarchy_3_description, hierarchy_4.code as hierarchy_4_code, hierarchy_4.description as hierarchy_4_description, hierarchy_5.code as hierarchy_5_code, hierarchy_5.description as hierarchy_5_description, itemgroup.code as group_code, item.description_2, item.description_3, harmonized_tariff.code as harmonized_tariff_code, harmonized_tariff.description as harmonized_tariff_description, uom.uom_name as min_dispatch_uom, item.nmfc_code, item.conversion_factor, item.image_data from item inner join company on company.id = item.company_id left outer join putaway_type on putaway_type.id = item.putawaytype_id left outer join item_characteristics on item_characteristics.item_id = item.id left outer join lpn_type on lpn_type.id = item_characteristics.ob_lpn_type_id left outer join item_metrics on item_metrics.item_id = item.id left outer join item_struct on item_struct.item_id = item.id left outer join item_hierarchy_defn as hierarchy_1 on hierarchy_1.id = item_struct.hierarchy_1_id left outer join item_hierarchy_defn as hierarchy_2 on hierarchy_2.id = item_struct.hierarchy_2_id left outer join item_hierarchy_defn as hierarchy_3 on hierarchy_3.id = item_struct.hierarchy_3_id left outer join item_hierarchy_defn as hierarchy_4 on hierarchy_4.id = item_struct.hierarchy_4_id left outer join item_hierarchy_defn as hierarchy_5 on hierarchy_5.id = item_struct.hierarchy_5_id left outer join item_group_defn as itemgroup on itemgroup.id = item_struct.group_id left outer join property_prompt_mode mode on mode.id = item_characteristics.serial_nbr_tracking_id left outer join harmonized_tariff on harmonized_tariff.id = item_characteristics.harmonized_tariff_id left outer join uom on uom.id = item_characteristics.min_dispatch_uom_id where item.company_id in (199)) wrE30  on (wrE17."od_item_id" = wrE30."id")
	WHERE wrE17."oh_order_nbr" = 'SO45028-1'
	ORDER BY wrE41."load_nbr" asc, wrE41."facility_id" asc, wrE14."batch_number" asc;