标签:tween case when 出现 from state left join select else cas
select case when sum(qty_sold*u.um03/u.um08) <> 0 then
decimal(coalesce(sum(d.amt_sold_with_tax)/sum(qty_sold*u.um03/u.um08),0), 18, 2)
else 0 end as value
from item_saleorg_day_2019 d
left join rpt_item_um u on d.item_id = u.item_id
left join dim_item i on d.item_id = i.item_id
where d.date1 between ‘20190101‘ and ‘20190106‘
出现下面的错误:
SQL0419N 十进制除法运算无效,因为结果将有一个负小数位。 SQLSTATE=42911
SQL改为下面就可以了:
select case when sum(qty_sold*u.um03/u.um08) <> 0 then
decimal(coalesce(sum(d.amt_sold_with_tax)/dec(sum(qty_sold*u.um03/u.um08),30,2),0), 18, 2)
else 0 end as value
from item_saleorg_day_2019 d
left join rpt_item_um u on d.item_id = u.item_id
left join dim_item i on d.item_id = i.item_id
where d.date1 between ‘20190101‘ and ‘20190106‘
SQL0419N 十进制除法运算无效,因为结果将有一个负小数位。 SQLSTATE=42911
标签:tween case when 出现 from state left join select else cas
原文地址:https://www.cnblogs.com/zmc/p/10231258.html