2016-11-13 99 views
0

我有以下由Date Asc订购的表。我需要渐进Netv列逐行列出Netv列作为eatch行。Oracle查询累积金额

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 

回答

1

你的问题有点不清楚。我的理解是,你想有这样的东西:

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