cumulative sum with weight ratio
Hi, I have column like this and I can do cumulative sum using
analytical function. The question is that if I want to apply weight
ratio to the sum. I mean , instead of adding the whole number from
previous row, I want to apply 60% weight onto the previous number and
40% to the current row.
How do I do it?
(In Excel, this is very easy.)
select sal from emp;
SAL
----------
800
1600
1250
2975
1250
2850
2450
3000
5000
1500
1100
950
3000
1300
14 rows selected.
select sal, sum(sal) over(order by empno) from emp;
SAL SUM(SAL)OVER(ORDERBYEMPNO)
---------- --------------------------
800 800
1600 2400
1250 3650
2975 6625
1250 7875
2850 10725
2450 13175
3000 16175
5000 21175
1500 22675
1100 23775
950 24725
3000 27725
1300 29025
14 rows selected.
(In Excel, this is very easy.)
select sal from emp;
SAL
----------
800
1600
1250
2975
1250
2850
2450
3000
5000
1500
1100
950
3000
1300
14 rows selected.
select sal, sum(sal) over(order by empno) from emp;
SAL SUM(SAL)OVER(ORDERBYEMPNO)
---------- --------------------------
800 800
1600 2400
1250 3650
2975 6625
1250 7875
2850 10725
2450 13175
3000 16175
5000 21175
1500 22675
1100 23775
950 24725
3000 27725
1300 29025
14 rows selected.
0