I have a table like:
ID MONTH VALUE
1 06/2014 3
1 07/2014 -2
1 08/2014 1
2 03/2014 1
2 04/2014 -1
(...)
What I want is to create a new column which hierarchically sum the values, like:
ID MONTH VALUE BALANCE
1 06/2014 3 3 <-- 3 + "0" (no previous)
1 07/2014 -2 1 <-- -2 + 3 (previous balance plus current value)
1 08/2014 1 2 <-- 1 + 1 (previous balance plus current value)
2 03/2014 1 1 <-- (...)
2 04/2014 -1
(...)
Possibly a way to use a connect by
clause here, just couldn't get my head around it.
I am using Oracle 11gR2
Ideas?