Giorgos Giorgos - 21 days ago 4
SQL Question

Oracle query cumulative amount

I have the following table that ordered by Date Asc. I need the column Progressively Netv that sum Progressively the column Netv for eatch row.

ID Type Date NetV Debit Credit Vat Progressively NetV
177485 Invoice 23/12/2015 900 1107 0 1.23 900
177485 transfer 14/1/2016 0 0 1107 0 900
177485 Invoice 24/3/2016 900 1107 0 1.23 1800
177485 transfer 27/5/2016 0 0 1107 0 1800
177485 Invoice 30/6/2016 900 1116 0 1.24 2700
177485 transfer 5/8/2016 0 0 1116 0 2700
177485 Invoice 28/9/2016 900 1116 0 1.24 3600
177485 transfer 4/11/2016 0 0 1116 0 3600

Answer

Your question is a bit unclear. What I understand is that you want to have something like:

  select id, type, date, NetV, Debit, Credit, Vat, 
         sum(NetV) over (partition by id order by date) as ProgressivelyNetV 
  from table1;
Comments