qq_20138291 2022-02-25 14:31 采纳率: 100%
浏览 24
已结题

SQL Sever如何在计算结果中增加一定百分比的损耗值,比如求和结果理论用量为10,需要加百分之十五的损耗率,就是用11.5

源代码:select a.OrderInfo1 '合同号',a.OrderInfo2 '柜体名称',a.OrderInfo3,a.OrderId '生产编号',a.Client '客户地址',a.Employee '拆单员',
case when CHARINDEX('银镜',Cpid)>0 then Cpid when cpid='铝箔纸' then '1404000100' when unit='米兰层板灯(拉丝金色)' then'1406000122' when unit='铝合金踢脚板(黑色)' then '1404000046' when unit='5mm透明玻璃' then '1306000097' else c.DetailName end DetailName,a.OrderCnt,
'五金' as [Datatype],case when Length>0 then cast(Length as nvarchar) else ' ' end,Width,c.Matname,case when unit = '3mm无铜磨边银镜' then '1405000063' else MatProducer end,case when DetailName='0501130027'then 1 else sum(Cnt) end as qty,
case when SysType=7 then MatProducer when c.ArticleID='BL_TM_05' then '块' when DetailName='0501130027'then '支' when detailname='1403000240' then '支' when unit='铝合金踢脚板(黑色)' then '块' when unit='米兰层板灯(拉丝金色)' then'套' when cpid='铝箔纸' then '块' when detailname='3mm无铜磨边银镜' then '块' else c.ArticleID end,
case when DetailName='1404000015' or DetailName='自攻丝40X30' then '自攻丝4X30' when detailname = '1403000240' then '铝合金踢脚板(铝色)' else Unit end unit,c.Thk,
case when Length>0 then cast(round(Length,0) as nvarchar)+'*'+ cast(round(Width,0) as nvarchar) else ' ' end ,(sum(Cnt) * Orderinfo3) as [合计],'' from T_BOM_Order a
inner join T_BOM_Item b on a.Id=b.Order_Id
inner join T_BOM_ItemDetail c on b.Id=c.Product_Id
where a.OrderId='csjstm' and SysType<>3
group by a.OrderInfo1,a.OrderInfo2,a.OrderInfo3,a.OrderId ,a.Client ,a.Employee,c.DetailName,a.OrderCnt,Length,Width,c.Matname,c.ArticleID,Unit,c.thk,SysType,MatProducer,Cpid

图片

img

当unit字符中包含金属卡条字眼的时候,333×0需要增加百分之十五的损耗,就是需要499.5×0

  • 写回答

2条回答 默认 最新

  • DarkAthena ORACLE应用及数据库设计方案咨询师 2022-02-25 15:27
    关注

    你这个sql里面其实已经有类似的写法了

    case when CHARINDEX('金属卡条',unit)>0 then 
              cast(round(Length*1.15, 0) as nvarchar) + '*' +
              cast(round(Width, 0) as nvarchar)
             end 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 3月8日
  • 已采纳回答 2月28日
  • 创建了问题 2月25日

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分