oracle query sequential summation per rows

前端 未结 2 443
时光说笑
时光说笑 2020-12-21 18:51

I would like to ask to make a query like the following table?

-------------------------------------
ID   Date        Input  Output  Total
-------------------         


        
2条回答
  •  鱼传尺愫
    2020-12-21 19:51

    Use SUM() OVER(..) window function which produce cumulative sum :

    SELECT t.id,t.date,t.input,t.output,
           SUM(t.output+t.input) OVER(PARTITION BY t.ID ORDER BY t.date) as Total
    FROM YourTable t
    

提交回复
热议问题