发布网友 发布时间:2022-04-22 13:17
共1个回答
热心网友 时间:2022-05-05 23:15
别忘了给最佳答案:)
算法exp(ln(a)+ln(b)+ln(c))=a*b*c,但ln()要求参数只能是正数,所以引入了abs()和sign()两个函数;另外如果乘数有0,乘积必为0。
select
case count(case sign(RATE) when 0 then 1 else null end)
when 0 then
case mod(sum(case sign(RATE) when -1 then 1 else 0 end),2)
when 1 then -1
else 1
end *
exp(sum(ln(abs(case RATE when 0 then null else RATE end))))
else 0
end "PRODUCT(RATE)"
from
(SELECT ID,PID,RATE
FROM TEST_TABLE
START WITH ID = '根节点' CONNECT BY PRIOR PID = ID);