что-то вроде этого должно сделать трюк
SELECT t1.EmployeeID
,t1.safe_id
,MAX(t1.salary)
,SUM(COALESCE(t2.subSalary, 0)) AS SubSalary
,MAX(t1.salary) - SUM(COALESCE(t2.subSalary, 0)) AS difference
FROM Table1 t1
LEFT JOIN Table2 t2 ON t1.emp_id = t2.emp_id
AND t1.safe_id = t2.safe_id
GROUP BY t1.EmployeeID
,t1.safe_id