SUM OVERを使用できます 機能: SELECT *, SUM(Input + Output) OVER(PARTITION BY ID ORDER BY Date) AS Total FROM table_a