What should i query to update the next ROW2 and so on which will be deducted from previous row.
Update tbl SET BAL= ''
Row 1 which has 10 QTY and 5 BAL
on the next Row 2, get the Previous BAL which is 5 then substract 1 QTY in Row 2, then update the Row 2 BAL = 4 and so on.
My Table
| Row | QTY | BAL |
|---|---|---|
| 1 | 10 | 5 |
| 2 | 1 | 0 |
| 3 | 4 | 0 |
DESIRED OUTPUT
| Row | QTY | BAL |
|---|---|---|
| 1 | 10 | 5 |
| 2 | 1 | 4 |
| 3 | 4 | 0 |
没有评论:
发表评论