i have a table like this:
"ID" "oamount"
'1' '1500'
'2' '2000'
'3' '2000'
'4' '1000'
and there is a buy order of 3000
so i need to select a query like this”
"ID" "oamount" "request"
'1' '1500' '1500'
'2' '2000' '1500'
and if the amount of the order is 4000 then
"ID" "oamount" "request"
'1' '1500' '1500'
'2' '2000' '2000'
'3' '2000' '500'
so i need to select all the rows until the amount is completed but the last row will represent the rest of the amount.
You could make it easier for yourself by adding an extra column, containing the sum of the amounts with a lower ID.
You can then select based on that new column:
You can do it without adding this extra column, but you’ll be making things unnecessarily hard.