select code, a.cost - isnull(b.cost,0) from table1 a left join table2 b on a.code = b.code
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)