zoukankan      html  css  js  c++  java
  • 公用表表达示展BOM示例

    公用表表达示展BOM示例,并计算累计用量。

    示例数据库为SQL示例数据库AdventureWorks,表名 Production.BillOfMaterials,Production.Product

    ;with bom as
    (
    select b.ProductAssemblyID,b.ComponentID,b.BOMLevel,b.PerAssemblyQty,cast(b.PerAssemblyQty as decimal(10,6)) qty,ROW_NUMBER() over(order by getdate()) od
    from Production.BillOfMaterials b where b.ComponentID=767
    union all
    select b.ProductAssemblyID,b.ComponentID,b.BOMLevel,b.PerAssemblyQty,cast(b.PerAssemblyQty*bom.qty as decimal(10,6)) ,ROW_NUMBER() over(order by getdate())+ bom.od*100
    from Production.BillOfMaterials b join bom on b.ProductAssemblyID=bom.ComponentID
    )
    select p.ProductNumber '物料编码',replicate('..',bom.bomlevel)+ p.Name '物料名称' ,bom.BOMLevel '层级',bom.PerAssemblyQty 'BOM用量',
    bom.qty '累计用量',bom.od '排序' from bom join Production.Product p on bom.ComponentID=p.ProductID
    order by rtrim(od)
  • 相关阅读:
    Some day some time we will do
    qemu-img 的使用
    虚拟化qemu-img的简单用法。
    linux 后台执行命令
    C#向服务器上传文件问题
    Canvas保存为图片
    一个Sql备注
    fabric Clone
    Js 正则获取Html元素
    Graphic 完成文字缩放
  • 原文地址:https://www.cnblogs.com/keewit/p/9643693.html
Copyright © 2011-2022 走看看