当postgres语句的第二部分必须放在第一部分时出现错误

时间:2018-08-17 17:54:14

标签: postgresql conditional

假设以下语句:

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条件下删除零大小写,并且使用对数时不能为零。

0 个答案:

没有答案