I have a query in PostgreSQL which yields:
itemorder name qty 1 A -20 2 A2 350 3 A 50 4 A -10 5 A2 10 the itemorder column gives the correct order of rows as I expect to see. I need to pass over the rows from bottom to top and calculate a new column that has an initial value of 100 and does + qty for each row of A.
itemorder name qty modifyed_sum 1 A -20 120 / 140 + (-20) 2 A2 350 140 / not A 3 A 50 140 / 90 + 50 4 A -10 90 / 100 + (-10) 5 A2 10 100 / not A How can I do that?