I would like to ask to make a query like the following table?
-------------------------------------
ID Date Input Output Total
-------------------
You can use SUM OVER
function:
SELECT *,
SUM(Input + Output) OVER(PARTITION BY ID ORDER BY Date) AS Total
FROM table_a
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