Subtracting sum of previous rows' data from current row's data in SQL
It seems you need a running total.

If tot_qty is the same in all rows then you can use

SELECT  id, 
        tot_qty, 
        rel_qty, 
        tot_qty - SUM(rel_qty) OVER (ORDER BY id ROWS UNBOUNDED PRECEDING) AS qoh 
FROM dbo.foo
ORDER BY id;


ROWS UNBOUNDED PRECEDING is the abbreviated version of ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW. 

This window frame-ing option means that for each row the SUM will include itself and all predecessors as ordered by id.

The ROWS option is potentially important for efficiency as described in Best approaches for running totals – updated for SQL Server 2012