壹佰网|ERP100 - 企业信息化知识门户

 找回密码
 注册

QQ登录

只需一步,快速开始

12
返回列表 发新帖
楼主: chen_7733

ERP系统常用SQL集锦(转)

[复制链接]
发表于 2008/8/29 16:00:13 | 显示全部楼层
太好了,谢谢楼主!太好了,谢谢楼主!太好了,谢谢楼主!
发表于 2012/2/20 15:39:20 | 显示全部楼层
技术型啊,学习...
发表于 2012/8/29 15:45:20 | 显示全部楼层
回复是一种友谊,一种美德★
发表于 2012/9/20 10:33:33 | 显示全部楼层
BOM 展开:
select DISTINCT
msi1.segment1 P_item,
to_char(b.lvl) LV,
c.Department_Code,
nvl(bom.alternate_bom_designator,'P') Alternate_bom_designator,
msi2.segment1 C_item,
c.Usage,
b.component_quantity Component_Qty
from inv.mtl_system_items_b msi1,
inv.mtl_system_items_b msi2,
bom.bom_bill_of_materials bom,
(select level lvl,
bic.bill_sequence_id,
bic.component_item_id,
bic.component_quantity,
bic.COMPONENT_YIELD_FACTOR,
bic.item_num,
bic.wip_supply_type,
bic.supply_subinventory,
bic.effectivity_date
FROM bom.bom_inventory_components bic
where disable_date IS NULL
start with bic.bill_sequence_id in
( select bill_sequence_id
from bom.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 = '98-222-13011'
and msi.organization_id = 89
and bom2.alternate_bom_designator is null
)
CONNECT BY bic.bill_sequence_id =
prior (SELECT distinct bill_sequence_id
FROM bom.bom_bill_of_materials BO,
inv.mtl_system_items_b msi
WHERE BO.assembly_item_id = bic.component_item_id
AND BO.organization_id = 89
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
)
) b,
(select msib.inventory_item_id inventory_item_id,
nvl(bor.alternate_routing_designator,'P') Alternate,
bd.department_code Department_Code,
sum(bore.usage_rate_or_amount) Usage
from inv.mtl_system_items_b msib,
bom.bom_operational_routings bor,
bom.bom_operation_sequences bos,
bom.bom_operation_resources bore,
bom.bom_departments bd,
bom. bom_resources br
where msib.inventory_item_id = bor.assembly_item_id
and msib.organization_id = bor.organization_id
and msib.organization_id = 89
and bor.routing_sequence_id = bos.routing_sequence_id
and bos.operation_sequence_id = bore.operation_sequence_id
and bos.department_id = bd.department_id
and bore.resource_id = br.resource_id
and bos.DISABLE_DATE is null
and bor.alternate_routing_designator is null
and bore.usage_rate_or_amount != 0
group by msib.inventory_item_id, bor.alternate_routing_designator, bd.department_code
) c
where b.bill_sequence_id = bom.bill_sequence_id
and bom.ORGANIZATION_ID = 89
and bom.ORGANIZATION_ID = msi1.ORGANIZATION_ID
and bom.ASSEMBLY_ITEM_ID = msi1.INVENTORY_ITEM_ID
and bom.ORGANIZATION_ID = MSI2.ORGANIZATION_ID
AND b.component_item_id = MSI2.INVENTORY_ITEM_ID
AND MSI2.SEGMENT1 not lIKE '98%'
AND MSI2.SEGMENT1 not like '99%'
and msi2.segment1 not like '90%'
and msi2.segment1 not like '97%'
and msi2.segment1 not like '92%'
and msi2.segment1 not like '95%'
and msi2.segment1 not like '65%'
and bom.ASSEMBLY_ITEM_ID = c.inventory_item_id
order by 2
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|手机版|壹佰网 ERP100 ( 京ICP备19053597号-2 )

Copyright © 2005-2012 北京海之大网络技术有限责任公司 服务器托管由互联互通
手机:13911575376
网站技术点击发送消息给对方83569622   广告&合作 点击发送消息给对方27675401   点击发送消息给对方634043306   咨询及人才点击发送消息给对方138011526

GMT+8, 2025/11/29 05:24 , Processed in 0.012199 second(s), 15 queries , File On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表