I have a table which looks as below :
select * from #tempTable
RN Qty 0 30 1 -3 2 -2 3 8
Using the below