語法, 如下 :
語法
SELECT MSI.SECONDARY_INVENTORY_NAME
, NVL(SUM(MMT.PRIMARY_QUANTITY), 0)
FROM MTL_MATERIAL_TRANSACTIONS MMT
, MTL_SECONDARY_INVENTORIES MSI
WHERE MMT.ORGANIZATION_ID = MSI.ORGANIZATION_ID
AND MMT.SUBINVENTORY_CODE = MSI.SECONDARY_INVENTORY_NAME
AND MMT.ORGANIZATION_ID = &ORGANIZATION_ID
AND MMT.INVENTORY_ITEM_ID = &INVENTORY_ITEM_ID
AND MMT.TRANSACTION_DATE BETWEEN TO_DATE('&START_DATE','YYYYMMDD') and (TO_DATE('&END_DATE','YYYYMMDD')+ 1)
AND MMT.TRANSACTION_SOURCE_TYPE_ID = 5
AND MMT.TRANSACTION_ACTION_ID = &ACTION_ID -- 1 (領料)
-- 27 (退料)
-- 33 (拆解工單領料)
-- 34 (拆解工單退料)
-- 31 (成品繳庫)
-- 32 (成品退回)
GROUP BY MSI.SECONDARY_INVENTORY_NAME;