Firstly, Hi Guys, sorry I've been away so long, I've taken on quite a large project and just haven't had the time for anything.
I am having difficulty completing my query. I initially have two tables
UserWallet
and Captures
So far my query creates a new table which displays a users total wallet value, what funds have already been captured from a users wallet, and what value remains in the users wallet. (In this table SearchID 1 would normally be omitted because no funds are remaining)
Search-Part1
I'm hoping in the same query I can do the following. Let's say someone has search for £200. The query is to start from the top row (Search-Part1) and work down until the value required is matched by the sum of the selected rows. e.g.
Search-Part2
So I'd like to be able to achieve the above. Search-Part2 has itterated down each row in Search-Part1 and added up the remaining value until the £200 has been filled. As you can see the last row of Search-Part2 is only using £25 of UserID 1005 because that is all that iss needed from the UEsers Wallet. I would be happy If I had to use (initially) all of UserID 1005 balance (£150) in the table as I'm happy requerying this at a later date to correct the value.
The final part of the Query which I can figure out simply adds Search-Part2 to the Captures Table
I hope I've managed to explain what I'm after. Its the Query to get the results from Search-Part1 to Search-Part2
Thanks