I have the following SQL table:
StockID Flow Stock 1 + 2 1 - 3 1 + 8 I have another table:
ID InStock 1 22 2 51 3 92 I want to select the first value of the second table 22 and add or subtract it cumulatively from the values Stock of the first table with the StockID = ID, based on the sign in the flow column. Then add/subtract the values in the column Stock from this solution.
This should appear in a new column Sol:
ID Flow Stock Sol 1 + 2 24 (22+2) 2 - 3 21 (24-3) 3 + 8 29 (21+8) Do you have any ideas?