Let's say I have this Table Rewards
CustomerID DateReceived Point
1 2020-01-01 15
1 2020-01-02 20
2 2020-01-08 20
2 2020-01-10 10
3 2020-01-10 50
Then I have this table MaxRewards
CustomerID MaxPoint
1 20
2 10
3 30
So, the idea is Customer's Point combined (summed) should never surpassed MaxPoint in MaxRewards table, if it does, then it will substract starting on latest date, so in the case above, the expected result should be
CustomerID DateReceived Point
1 2020-01-01 15
1 2020-01-02 5
2 2020-01-08 10
2 2020-01-10 0
3 2020-01-10 30
How do I execute a query to update the table without a loop? I've been thinking of using CROSS APPLY but I can't seem to get it right.

