日期:2014-05-17  浏览次数:20447 次

求SQL语句 关于BOM展料
大家好!
   现在我已经将BOM全部展开了.现在是当某一物料的标志为Y时,其下阶的物料将不会展出来.见下表.备注"00010002"、备注"00030002"的标志位为"Y"其下阶就不用展示出来。即红色字体不用展示出来。


谢谢!

------解决方案--------------------
with cte --查询出所有不应该显示出来的数据列表
as
(
select a.备注
from
bom a inner join bom b on (a.备注<>b.备注)
where b.标志='Y' and  a.备注 like 'b.备注%'
)
select *
from
bom t
where not exists
(
select *
from
cte 
where t.备注=cte.备注
)