-2

hi guys I have a simple question about how to use the funcion MSUM of Oracle BI in sql developer, I don't even know if this is posible, it is?

Jos torres
  • 13
  • 2
  • Please be more specific. By MSUM, do you mean a **cumulative sum** function? Example: https://stackoverflow.com/a/5462250/3061852 – kfinity Sep 27 '18 at 20:10
  • Can you give us an example of some data and what you want the result to be? – kfinity Sep 27 '18 at 20:11

1 Answers1

0

Based on your example data, here's how I would do a moving sum (or cumulative sum). You can find more info in Oracle Analytic Functions.

create table test (id number, value number);
insert into test values (1, 100);
insert into test values (2, 300);
insert into test values (3, 500);
insert into test values (4, 800);

select id, value,
    sum(value) over (order by id rows between unbounded preceding and current row) as total
from test
order by id;

Output:

1   100 100
2   300 400
3   500 900
4   800 1700
kfinity
  • 8,581
  • 1
  • 13
  • 20