17,082
社区成员
发帖
与我相关
我的任务
分享
select a.partno,a.version,b.data2 from purgebomlist a,sys_ctl b where b.sys='PVERSION' and b.ctl_id='PART' and ctl_type='PART_VERSION' and a.version=b.data
以上的表sys_ctl是由A到ZZ的一个排序比较,就是把A到ZZ转换成001到702来比对版本大小
with T as (
select a.partno,a.constituentpartno,a.version,a.iteration,a.plocation,a.phantom,a.isassembly,constituentpartqty,constituentpartunit,drawing,changenumber,modifier,effectivedate
from purgebomlist a,(
select partno,version,max(iteration) as iteration
from(
select a.partno,b.version,a.iteration
from purgebomlist a,(
select a.partno,b.data as version
from(
select partno,MAX(data2) as version
from (select a.partno,a.version,b.data2 from purgebomlist a,sys_ctl b where b.sys='PVERSION' and b.ctl_id='PART' and ctl_type='PART_VERSION' and a.version=b.data)
group by partno) a,sys_ctl b
where b.sys='PVERSION' and b.ctl_id='PART' and ctl_type='PART_VERSION' and a.version=b.data2) b
where a.partno=b.partno and a.version=b.version
)
group by partno,version
) b
where a.partno=b.partno and a.version=b.version and a.iteration=b.iteration
)
select constituentpartno,partno,version,iteration,level,plocation,phantom,isassembly,constituentpartqty,constituentpartunit,drawing,changenumber,modifier,effectivedate
from T
start with partno='最上层成品' and version='E' and iteration='1'
connect by prior constituentpartno=partno
with T as (
select child,parent,
MAX(version) KEEP(DENSE_RANK LAST ORDER BY version,iteration,ROWID) version,
MAX(iteration) KEEP(DENSE_RANK LAST ORDER BY version,iteration,ROWID) iteration
from bomlist
group by parent,child
)
select child,parent,level,version,iteration
from T
start with parent='parentNumber'
connect by prior child=parent