I have a SQL query that has the total on hand qty and another column that has a qty that I need to subtract from the on hand until it all get consumed .
On hand = 50
So I need a column that will have
40 (from 50-10)
25 ( from 40 - 15)
15 ( from 25-10)
-5 ( from 15-20)
How can I accomplish this using transact sql