select distinct t.demandNo from t_aaa t, t_bbb o where 1=1 and t.Id=o.Id and t.demandNo not in (select t.demandNo from t_aaa t, t_bbbo where 1=1 and t ...
select distinct t.demandNo
from t_aaa t, t_bbb o
where 1=1 and t.Id=o.Id
and t.demandNo not in
(select t.demandNo from t_aaa t, t_bbbo where 1=1 and t.Id=o.Id and o.status=3 order by t.demandNo DESC)