--■■■having句でall述語を使う方法■■■
select ID
from (select 1 as ID,1 as Flag from dual
union all select 1,1 from dual
union all select 1,0 from dual
union all select 2,1 from dual
union all select 2,1 from dual
union all select 3,3 from dual
union all select 3,0 from dual
union all select 3,0 from dual)
group by ID
having 1 = all(min(Flag),max(Flag));
--■■■having句でdecode関数を使う方法■■■
select ID
from (select 1 as ID,1 as Flag from dual
union all select 1,1 from dual
union all select 1,0 from dual
union all select 2,1 from dual
union all select 2,1 from dual
union all select 3,3 from dual
union all select 3,0 from dual
union all select 3,0 from dual)
group by ID
having min(decode(Flag,1,1,0)) = 1;