Select *, (x.A+x.B-x.C) as "D" From (
select E.EmpCode,
(select count (D.id) from Dept D where D.Location = E.Location) as "A"),
(select count (D.id) from Add D where D.Location = E.Location) as "B"),
(select count (D.id) from Dept D where D.DeptName = E.DeptName) as "C")
from Employees E) x