postgresql7.1 select p.party_id, acs_object__name(p.party_id) as name, p.email from parties p where not exists (select 1 from wf_task_assignments ta where ta.task_id = :task_id and ta.party_id = p.party_id) and 0 < (select count(*) from users u, party_approved_member_map m where m.party_id = p.party_id and u.user_id = m.member_id)