SELECT DISTINCT u.email AS "email", u.is_active AS "is_active", h.id AS "house_id" FROM house c INNER JOIN (SELECT DISTINCT house_id,