select *
from Pass_Head ph
left (
select distinct P_PASS_NO FROM
PASS_HEAD WHERE STATUS!=7) ph2 on ph2.P_PASS_NO=ph.PASS_NO
WHERE ph2.P_PASS_NO IS NULL
select *
from Pass_Head ph
left (
select distinct P_PASS_NO FROM
PASS_HEAD WHERE STATUS!=7) ph2 on ph2.P_PASS_NO=ph.PASS_NO
WHERE ph2.P_PASS_NO IS NULL