2021年2月7日星期日

Update Value in next Row MYSQL

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
https://stackoverflow.com/questions/66095213/update-value-in-next-row-mysql February 08, 2021 at 10:30AM

没有评论:

发表评论