順展BOM實用SQL
依網上貼略有整理.[@more@]SELECT distinct
bb.BOMcc,
bb.zhpeijian,
bb.zhpeijiandesc,
bb.SUB_SEQUENCE,
bb.SUB_ITEM,
bb.SUB_ITEMDESC,
bb.component_quantity,
bb.UOM,
bb.LYL_RATE,
bb.SUBINV,
bb.LOCATION,
bb.ITEM_TYPE,
bb.BOMtimes,
BOR.COMPLETION_SUBINVENTORY ,--入庫,
MSI.WIP_SUPPLY_SUBINVENTORY,-- 沖減,
MSI.MAXIMUM_ORDER_QUANTITY ,-- 最大批次,
MSI.LEAD_TIME_LOT_SIZE ,-- 提前期,
MSI.FULL_LEAD_TIME ,-- 製造週期,
MSI.FIXED_LOT_MULTIPLIER ,-- 固定增加,
MSI.MINIMUM_ORDER_QUANTITY ,--最小批次,
MSI.FIXED_ORDER_QUANTITY ,-- 固定定貨量,
MSI.FIXED_DAYS_SUPPLY ,-- 固定天數,
MSI.PLANNER_CODE -- 計畫員
FROM MTL_SYSTEM_ITEMS MSI,
BOM_OPERATIONAL_ROUTINGS BOR,
BOM_OPERATION_SEQUENCES BOS,
(select distinct
aa.lvl BOMcc,
msi.segment1 zhpeijian,
msi.description zhpeijiandesc,
aa.item_num SUB_SEQUENCE,
msi1.segment1 SUB_ITEM,
msi1.description SUB_ITEMDESC,
aa.component_quantity ,
msi1.primary_unit_of_measure UOM,
aa.COMPONENT_YIELD_FACTOR LYL_RATE,
msi1.wip_supply_subinventory SUBINV,
mil.segment1 || '.' || mil.segment2 || '.' || mil.segment3 || '.' ||
mil.segment4 LOCATION,
decode(msi1.planning_make_buy_code,1,'SUB',2,'PUR') ITEM_TYPE,
to_char(msi1.creation_date,'yyyy.mm.dd hh24:mm.ss') BOMtimes,
msi1.inventory_item_id
from mtl_system_items_b msi,
mtl_system_items_b msi1,
bom_bill_of_materials bom,
bom_inventory_components bic,
mtl_item_locations mil,
(
select level lvl,
bic.bill_sequence_id,
bic.component_item_id,
bic.component_quantity,
bic.OPERATION_SEQ_NUM,
bic.COMPONENT_YIELD_FACTOR,
bic.COMPONENT_SEQUENCE_ID,
bic.item_num,
bic.wip_supply_type,
bic.supply_subinventory,
bic.effectivity_date
FROM bom_inventory_components bic
where disable_date IS NULL
start with bic.bill_sequence_id in
(select bill_sequence_id
from bom_bill_of_materials bom2,
inv.mtl_system_items_b msi
where bom2.assembly_item_id = msi.inventory_item_id
and bom2.organization_id = msi.organization_id
and msi.segment1 ='500012NCP'
and msi.organization_id =803 -- 組織ID
and bom2.alternate_bom_designator is null)
CONNECT BY bic.bill_sequence_id in prior
(SELECT distinct bill_sequence_id
FROM bom_bill_of_materials BO, inv.mtl_system_items_b msi
WHERE BO.assembly_item_id = bic.component_item_id
AND BO.organization_id = 803 --組織ID
and bo.ORGANIZATION_ID = msi.ORGANIZATION_ID
and bo.ASSEMBLY_ITEM_ID = msi.INVENTORY_ITEM_ID
and bo.alternate_bom_designator is null
and disable_date IS NULL)) aa
where msi.organization_id=803 --組織ID
and msi1.organization_id=803 --組織ID
and bom.organization_id=803 --組織ID
and msi.inventory_item_id=bom.assembly_item_id
and bom.bill_sequence_id=bic.bill_sequence_id
and bic.component_item_id=msi1.inventory_item_id
and bic.disable_date is null
and aa.bill_sequence_id=bic.bill_sequence_id
and aa.component_item_id=msi1.inventory_item_id
and mil.inventory_location_id(+)=msi1.wip_supply_locator_id
and mil.organization_id(+)=803 --組織ID
order by
aa.lvl,
aa.item_num) bb
WHERE BOR.ASSEMBLY_ITEM_ID(+) = MSI.INVENTORY_ITEM_ID
AND BOS.ROUTING_SEQUENCE_ID(+) = BOR.ROUTING_SEQUENCE_ID
AND MSI.ORGANIZATION_ID(+) =803 -- 組織ID
and bor.alternate_routing_designator is null
and bb.inventory_item_id=msi.inventory_item_id
order by
bb.BOMcc,
bb.zhpeijian,
bb.zhpeijiandesc,
bb.sub_SEQUENCE,
bb.sub_item
bb.BOMcc,
bb.zhpeijian,
bb.zhpeijiandesc,
bb.SUB_SEQUENCE,
bb.SUB_ITEM,
bb.SUB_ITEMDESC,
bb.component_quantity,
bb.UOM,
bb.LYL_RATE,
bb.SUBINV,
bb.LOCATION,
bb.ITEM_TYPE,
bb.BOMtimes,
BOR.COMPLETION_SUBINVENTORY ,--入庫,
MSI.WIP_SUPPLY_SUBINVENTORY,-- 沖減,
MSI.MAXIMUM_ORDER_QUANTITY ,-- 最大批次,
MSI.LEAD_TIME_LOT_SIZE ,-- 提前期,
MSI.FULL_LEAD_TIME ,-- 製造週期,
MSI.FIXED_LOT_MULTIPLIER ,-- 固定增加,
MSI.MINIMUM_ORDER_QUANTITY ,--最小批次,
MSI.FIXED_ORDER_QUANTITY ,-- 固定定貨量,
MSI.FIXED_DAYS_SUPPLY ,-- 固定天數,
MSI.PLANNER_CODE -- 計畫員
FROM MTL_SYSTEM_ITEMS MSI,
BOM_OPERATIONAL_ROUTINGS BOR,
BOM_OPERATION_SEQUENCES BOS,
(select distinct
aa.lvl BOMcc,
msi.segment1 zhpeijian,
msi.description zhpeijiandesc,
aa.item_num SUB_SEQUENCE,
msi1.segment1 SUB_ITEM,
msi1.description SUB_ITEMDESC,
aa.component_quantity ,
msi1.primary_unit_of_measure UOM,
aa.COMPONENT_YIELD_FACTOR LYL_RATE,
msi1.wip_supply_subinventory SUBINV,
mil.segment1 || '.' || mil.segment2 || '.' || mil.segment3 || '.' ||
mil.segment4 LOCATION,
decode(msi1.planning_make_buy_code,1,'SUB',2,'PUR') ITEM_TYPE,
to_char(msi1.creation_date,'yyyy.mm.dd hh24:mm.ss') BOMtimes,
msi1.inventory_item_id
from mtl_system_items_b msi,
mtl_system_items_b msi1,
bom_bill_of_materials bom,
bom_inventory_components bic,
mtl_item_locations mil,
(
select level lvl,
bic.bill_sequence_id,
bic.component_item_id,
bic.component_quantity,
bic.OPERATION_SEQ_NUM,
bic.COMPONENT_YIELD_FACTOR,
bic.COMPONENT_SEQUENCE_ID,
bic.item_num,
bic.wip_supply_type,
bic.supply_subinventory,
bic.effectivity_date
FROM bom_inventory_components bic
where disable_date IS NULL
start with bic.bill_sequence_id in
(select bill_sequence_id
from bom_bill_of_materials bom2,
inv.mtl_system_items_b msi
where bom2.assembly_item_id = msi.inventory_item_id
and bom2.organization_id = msi.organization_id
and msi.segment1 ='500012NCP'
and msi.organization_id =803 -- 組織ID
and bom2.alternate_bom_designator is null)
CONNECT BY bic.bill_sequence_id in prior
(SELECT distinct bill_sequence_id
FROM bom_bill_of_materials BO, inv.mtl_system_items_b msi
WHERE BO.assembly_item_id = bic.component_item_id
AND BO.organization_id = 803 --組織ID
and bo.ORGANIZATION_ID = msi.ORGANIZATION_ID
and bo.ASSEMBLY_ITEM_ID = msi.INVENTORY_ITEM_ID
and bo.alternate_bom_designator is null
and disable_date IS NULL)) aa
where msi.organization_id=803 --組織ID
and msi1.organization_id=803 --組織ID
and bom.organization_id=803 --組織ID
and msi.inventory_item_id=bom.assembly_item_id
and bom.bill_sequence_id=bic.bill_sequence_id
and bic.component_item_id=msi1.inventory_item_id
and bic.disable_date is null
and aa.bill_sequence_id=bic.bill_sequence_id
and aa.component_item_id=msi1.inventory_item_id
and mil.inventory_location_id(+)=msi1.wip_supply_locator_id
and mil.organization_id(+)=803 --組織ID
order by
aa.lvl,
aa.item_num) bb
WHERE BOR.ASSEMBLY_ITEM_ID(+) = MSI.INVENTORY_ITEM_ID
AND BOS.ROUTING_SEQUENCE_ID(+) = BOR.ROUTING_SEQUENCE_ID
AND MSI.ORGANIZATION_ID(+) =803 -- 組織ID
and bor.alternate_routing_designator is null
and bb.inventory_item_id=msi.inventory_item_id
order by
bb.BOMcc,
bb.zhpeijian,
bb.zhpeijiandesc,
bb.sub_SEQUENCE,
bb.sub_item
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/92289/viewspace-1038918/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 標準API展開BOM程式碼API
- Sql執行順序SQL
- SQL SERVER實用技巧SQLServer
- 用pandas實現SQL功能SQL
- SQL語句執行順序SQL
- SQL 優先順序join>whereSQL
- sql mysql 執行順序 (4)MySql
- 字元編碼發展史6 — BOM位元組序標記字元
- BOM操作
- SQL 語句的執行順序SQL
- sql select語法執行順序SQL
- DOM和BOM
- BOM-篇
- JS-bomJS
- BOM – Clipboard APIAPI
- 實驗二:順序表的基本操作實現及其應用
- SQL語句各子句的執行順序SQL
- 「Python實用祕技07」在pandas中實現自然順序排序Python排序
- JavaScript DOM、BOM操作JavaScript
- mysql 中sql語句關鍵字的書寫順序與執行順序MySql
- 一份python實用”技巧“清單(按字母順序)Python
- SQL 查詢語句的執行順序解析SQL
- Hive SQL語句的正確執行順序HiveSQL
- SQL語句中的AND和OR執行順序問題SQL
- 順序表應用5:有序順序表歸併
- 順序表應用6:有序順序表查詢
- js中的BOM物件JS物件
- BOM學習總結
- JavaScript(ECMAScript+BOM+DOM)JavaScript
- javaScript事件,Bom,Dom物件JavaScript事件物件
- 什麼是BOM物件物件
- 順應數實融合發展趨勢,天美正向價值探索再升級
- 實用型順豐保價讓你花小錢辦大事
- SQL從零到迅速精通【實用函式(2)】SQL函式
- 記一個實用的sql查詢語句SQL
- 五個實用的SQL Server PowerShell指令碼OMSQLServer指令碼
- sql語句執行順序與效能優化(1)SQL優化
- ORACLE中sql語句----運算子的優先順序OracleSQL
- 你瞭解一條sql的執行順序嗎SQL