oracle query sequential summation per rows

前端 未结 2 444
时光说笑
时光说笑 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:28

    You can use SUM OVER function:

    SELECT *,
        SUM(Input + Output) OVER(PARTITION BY ID ORDER BY Date) AS Total
    FROM table_a
    

提交回复
热议问题