How can I return a cumulative value in a raw dataset?
raw data:
ID VALUE
-- -----
1 5
2 7
3 2
desired result:
ID VALUE CUMULATIVE_VALUE
-- ----- ----------------
1 5 5
2 7 12
3 2 14
Printable View
How can I return a cumulative value in a raw dataset?
raw data:
ID VALUE
-- -----
1 5
2 7
3 2
desired result:
ID VALUE CUMULATIVE_VALUE
-- ----- ----------------
1 5 5
2 7 12
3 2 14
have a look in the sql reference for "Analytic Functions". They do exactly this, and look something like ...
select id,value,
sum(value) over (order by id range unbounded preceeding)
from my_table