I am building a program in which the user enters a value, either negative or positive, and this value is added to the table, and through the SELECT statement, those values are stored and the remaining values are found in a new column, and at each entry, the data of the DataGridView is updated.
Example:
| Date | Number | Remaining | 
|---|---|---|
| 07-06-2021 | 20,000 | 20,000 | 
| 07-06-2021 | 15,000 | 35,000 | 
| 09-06-2021 | 21,000 | 56,000 | 
| 30-06-2021 | – 30,000 | 26,000 | 
| 01-07-2021 | – 20,000 | 6,000 | 
Advertisement
Answer
Your remaining column looks like a cumulative sum.  In SQL, you would use:
select date, number,
       sum(number) over (order by date rows between unbounded preceding and current row)
from t;