Hemanth Komaravolu
Hemanth Komaravolu

Reputation: 29

Query in Oracle for running sum

I need to pull the result set with sum of the previous record and current record.

Logic

My table is having one key column C1 and a numeric column C2. I need a result like below example. I need 3 columns as the out put out which 1 columns is with running sum. First two columns are same as source with the thrid columns but

and it should continue for all the records.

Ex. I have one source table like

C1     C2
---------
a       1
b       2
c       3

I Need output like below

C1   C2   C3
-------------
a    1    1
b    2    3
c    3    6

Upvotes: 0

Views: 200

Answers (1)

Dmitriy
Dmitriy

Reputation: 5565

select c1, c2, sum(c2) over (order by c2) c3
  from table_name

Upvotes: 4

Related Questions