SELECT Bld.id,C.code,M.FIRST_NAME,M.LAST_NAME,Bld.Address,M.ADDRESS,D.DOB, '0' AS S.SALARY
from HW1_PERSON M
inner join HW1_BUILDING Bld
ON M.id = Bld.id
INNER JOIN HW1_PERSON M
ON Bld.id = M.id
INNER JOIN HW1_PERSON M
ON M.id = Bld.id
Inner JOIN HW1_BUILDING Bld
ON Bld.id = M.id
INNER JOIN HW1_BUILDING C
ON M.id = C.id
INNER JOIN HW1_PERSON D
ON M.id = D.id
UNION ALL
SELECT Bld.id,C.code,M.FIRST_NAME,M.LAST_NAME,Bld.Address,M.ADDRESS,D.DOB,S.SALARY FROM HW1_STAFF S
where S.SALARY = NULL
;
I Вашата първа колона за заявка не съществува S.SALARY, така че задайте по подразбиране '0' ИЛИ ''