Это в SQL Server, но логика, кажется, работает, повторяя Криса выше:
declare @house table
(
houseid int
)
declare @person table
(
personid int,
houseid int,
personstatus varchar(20)
)
insert into @house (houseid) VALUES (1)
insert into @house (houseid) VALUES (2)
insert into @house (houseid) VALUES (3)
insert into @house (houseid) VALUES (4)
insert into @person (personid, houseid, personstatus) VALUES (1, 1, 'CANCELLED')
insert into @person (personid, houseid, personstatus) VALUES (2, 1, 'CANCELLED')
insert into @person (personid, houseid, personstatus) VALUES (3, 1, 'ACTIVE')
insert into @person (personid, houseid, personstatus) VALUES (1, 2, 'ACTIVE')
insert into @person (personid, houseid, personstatus) VALUES (4, 4, 'CANCELLED')
select * from @house
select * from @person
select *
from @house h LEFT OUTER JOIN @person p ON h.houseid = p.houseid
AND p.personstatus <> 'CANCELLED'