我有一张下表用于应付
设想:
We are going to pay 6000 to our vendor, this payment apply on 2nd row and remaining 2500 apply on 3rd row. after apply the 2500 on 3rd row , there will be a remaining balance of 1000.
Now I want to write a query that return number of rows base on payment enter. The conditions of query are as follow:
- 检查余额大于0
- 仅返回付款适用的行。
i.e. In above scenario, payment was 6000, and then query check that in which 6000 apply, base upon that decision it should return rows. In 6000 case he should return 2nd and 3rd row, if payment = 8000 then query will return 3 row because 7000 satisfy/ clear 2nd & 3rd payable and remaining 1000 will reduce the balance of 4th entry.
我想要一个只返回付款适用的行数的查询?
让我知道 !