假设以下语句:
select
case when max(api_discountitem.amount)=100.0 then 0.0 else exp(sum(log(1.0 - (api_discountitem.amount/100.0)))) end as sum_discount
from
api_discountitem join api_sellitem_discounts on api_sellitem_discounts.discountitem_id=api_discountitem.id
group by
api_sellitem_discounts.sellitem_id;
它会产生cannot take logarithm of zero
错误,但我会在when
条件下删除零大小写,并且使用对数时不能为零。