SELECT dtl.organization_id,

dtl.inventory_item_id,

dtl.segment1,

dtl.revision,

dtl.subinventory_code,

dtl.locator_id,

dtl.lot_number,

dtl.primary_uom_code,

SUM(dtl.primary_transaction_quantity) primary_transaction_quantity

FROM (

--Onhand Quantity

SELECT moq.organization_id,

moq.inventory_item_id,

mst.segment1,

moq.revision,

moq.subinventory_code,

moq.locator_id,

moq.lot_number,

mst.primary_uom_code,

moq.primary_transaction_quantity

FROM inv.mtl_onhand_quantities_detail moq,

inv.mtl_system_items_b           mst

WHERE moq.organization_id = mst.organization_id

AND moq.inventory_item_id = mst.inventory_item_id

AND moq.is_consigned = 2

--Filter

AND moq.organization_id = 33

AND mst.segment1 = '00088035800'

UNION ALL

SELECT mmt.organization_id,

mmt.inventory_item_id,

mst.segment1,

mmt.revision,

mmt.subinventory_code,

mmt.locator_id,

lot.lot_number,

mst.primary_uom_code,

-nvl(lot.primary_quantity, mmt.primary_quantity) primary_transaction_quantity

FROM inv.mtl_material_transactions   mmt,

inv.mtl_transaction_lot_numbers lot,

inv.mtl_system_items_b          mst

WHERE mmt.transaction_id = lot.transaction_id(+)

AND mmt.organization_id = mst.organization_id

AND mmt.inventory_item_id = mst.inventory_item_id

--Filter

AND mmt.organization_id = 33

AND mst.segment1 = '00088035800'

AND mmt.transaction_date >=

to_date('2006-12-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')) dtl

GROUP BY dtl.organization_id,

dtl.inventory_item_id,

dtl.segment1,

dtl.revision,

dtl.subinventory_code,

dtl.locator_id,

dtl.lot_number,

dtl.primary_uom_code

HAVING SUM(dtl.primary_transaction_quantity) <> 0;

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐