Oracle实现连乘和求和
---创建测试表
CREATE TABLE LUCKYTEST( PARENT_ID NUMBER, PART_ID NUMBER, QUALITY NUMBER); INSERT INTO TEST LUCKYTEST(1,1,2); INSERT INTO TEST LUCKYTEST(1,2,3); INSERT INTO TEST LUCKYTEST(1,3,2); INSERT INTO TEST LUCKYTEST(1,4,5); INSERT INTO TEST LUCKYTEST(2,2,3); INSERT INTO TEST LUCKYTEST(2,3,5); INSERT INTO TEST LUCKYTEST(2,4,7);
一、实现累加
SELECT SUM(QUALITY) FROM LUCKYTEST
二、实现累积
SELECT EXP(SUM(LN(T.QUALITY))) FROM LUCKYTEST T