|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
WITH TEMP AS(
SELECT CJ=CAST(BOM_NO+prd_no+'->' AS nvarchar(100)),BOM_NO,PRD_NO,WH,QTY,ID_NO,CST,LEV=0, cast(qty as decimal)fqty FROM BOM_TF WHERE bom_no in ('14012002->','14012001->')
UNION ALL
SELECT CJ=CAST(CJ +ISNULL(T2.PRD_no,'')+'->' AS nvarchar(100)), T2.*,LEV=LEV+1 ,cast(T2.qty *fqty as decimal) FROM (
SELECT BOM_NO,PRD_NO,WH,QTY,ID_NO,CST FROM BOM_TF )T2,TEMP T3
WHERE T3.id_no=T2.bom_no
)
SELECT SUBSTRING('.....',1,lev+1)+cast( lev+1 as char(10))xx,* FROM TEMP ORDER BY CJ
|
|