Monday, 16 July 2012

item lotnumber query

/* Formatted on 2012/07/16 15:26 (Formatter Plus v4.8.8) */
SELECT xxstg.item, msi.description, cst.item_cost COST,
       mtsn.serial_number lot_number,
       mtsn.current_subinventory_code sub_inventory,
       (   mtil.segment1
        || ','
        || mtil.segment2
        || ','
        || mtil.segment3
        || ','
        || mtil.segment4
        || ','
        || mtil.segment5
       ) LOCATOR,
       mmt.transaction_quantity quantity            --msi.SOURCE_SUBINVENTORY,
  FROM xxmtz_inv_scan_trans_stg xxstg,
       mtl_system_items_b msi,
       cst_item_costs cst,
       mtl_serial_numbers mtsn,
       mtl_item_locations mtil,
       mtl_material_transactions mmt
 WHERE 1 = 1
   /*  xxmtz_inv_scan_trans_stg --- mtl_item_locations */
   AND xxstg.inventory_item_id = msi.inventory_item_id
   /* cst_item_costs cst  --- xxmtz_inv_scan_trans_stg */
   AND cst.inventory_item_id = xxstg.inventory_item_id
   /* cst_item_costs cst  --- mtl_system_items_b */
   AND cst.inventory_item_id = msi.inventory_item_id
   AND msi.organization_id = cst.organization_id
   /* mtl_system_items_b ---  mtl_serial_numbers */
   AND msi.inventory_item_id = mtsn.inventory_item_id
   AND mtsn.current_organization_id = msi.organization_id
   /* mtl_item_locations ---  mtl_item_locations --  xxmtz_inv_scan_trans_stg  -- cst_item_costs */
   AND mtil.inventory_item_id = msi.inventory_item_id
   AND msi.organization_id = mtil.organization_id
   AND xxstg.inventory_item_id = mtil.inventory_item_id
   AND cst.inventory_item_id = mtil.inventory_item_id
   /* mtl_item_locations ---  mtl_item_locations --  xxmtz_inv_scan_trans_stg  -- cst_item_costs --mtl_material_transactions */
   AND mmt.inventory_item_id = msi.inventory_item_id
   AND mmt.organization_id = mtil.organization_id
   AND mmt.inventory_item_id = mtil.inventory_item_id
   AND mmt.organization_id = msi.organization_id
   AND xxstg.inventory_item_id = mmt.inventory_item_id
   AND cst.inventory_item_id = mmt.inventory_item_id
   AND xxstg.item not in ('CEQ.26540','CEQ.27416','CEQ.22254','CEQ.26209','CEQ.26208','CEQ.30263','NEQ.01529','CEQ.OUTDOOR','ANT.12071','CEQ.71934','NEQ.12371',
   'CEQ.26210','CEQ.10483','CEQ.27355','CEQ.32045','CEQ.10372','CEQ.71936','WIRELESS BTS')

No comments:

Post a Comment