一句SQL搞定BOM展尾阶

来源:互联网 发布:淘宝网首页轮播广告费 编辑:程序博客网 时间:2024/05/22 10:35

select '第 '||a.L||' 层' 层级,(case (L)
when 0 then '0'       
when 1 then '.1'      
when 2 then '..2'
when 3 then '...3'    
when 4 then '....4'   
when 5 then '.....5'
when 6 then '......6' 
when 7 then '.......7' 
end) Lev,
a.bmb03 料号,ima02 品名,ima021 规格,a.bmb06 组成用量,a.bmb07 底数,
a.bmb08 损耗率,a.bmb10 发料单位,ima08 来源码,ima18 产品单重
from (
select 0 L,bma01 bmb03,0 bmb06,0 bmb07,0 bmb08,'' bmb10
from bma_file
where bma01='0055-JG01-000J'
UNION
select level L,bmb03,bmb06,bmb07,bmb08,bmb10
from bmb_file
where bmb05 is null
start with bmb01= '0055-JG01-000J'
connect by prior bmb03=bmb01) a,ima_file
where a.bmb03=ima01

 

0 0