【问题标题】:Not able to use calculated value in CONCAT statement无法在 CONCAT 语句中使用计算值
【发布时间】:2020-02-24 22:41:17
【问题描述】:
Case when sim.PickPackUom='IP' then  sim.InnerPackQuantity 
else 
   im.CaseQuantity
end 
  as divqty
,concat (cast (i.QuantityOnHand as float)/divqty  ,' ',  sim.PickPackUom  )qty

concat 给出错误。如何使 divqty 值可用于 concat 或除法?

【问题讨论】:

  • 使其成为子选择的一部分
  • 哪个错误给你?
  • 用您正在使用的数据库标记您的问题。

标签: sql case concat divide


【解决方案1】:

你必须使用整个 case 条件而不是 divqty:

Case when sim.PickPackUom='IP' then  sim.InnerPackQuantity 
    else im.CaseQuantity
    end as divqty
,concat (
       cast (i.QuantityOnHand as float)/
             (Case when sim.PickPackUom='IP' then  sim.InnerPackQuantity 
                   else im.CaseQuantity end),
       ' ',  sim.PickPackUom) qty

【讨论】:

    猜你喜欢
    • 2023-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-11
    • 2021-12-04
    • 2016-03-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多