我有下表由Date Asc订购。我需要逐步将Netv列作为eatch行列的渐进式Netv。
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
答案 0 :(得分:1)
你的问题有点不清楚。我的理解是你希望有类似的东西:
select id, type, date, NetV, Debit, Credit, Vat,
sum(NetV) over (partition by id order by date) as ProgressivelyNetV
from table1;