无法在CONCAT语句中使用计算值

问题描述 投票:0回答:1
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个回答
1
投票

您必须使用整个案例条件而不是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
热门问题
推荐问题
最新问题