create table demo(
CLM1 number(1),
CLM2 number(1),
CLM3 char(1),
primary key(CLM1,CLM2,CLM3));
insert into demo values(1,1,'A');
insert into demo values(1,1,'B');
insert into demo values(1,1,'C');
insert into demo values(1,1,'D');
insert into demo values(1,1,'E');
insert into demo values(1,2,'F');
insert into demo values(1,2,'G');
insert into demo values(1,2,'H');
insert into demo values(1,2,'I');
insert into demo values(1,3,'J');
insert into demo values(2,3,'K');
insert into demo values(2,3,'L');
insert into demo values(2,3,'M');
insert into demo values(2,3,'N');
insert into demo values(2,3,'O');
insert into demo values(2,4,'P');
insert into demo values(2,4,'Q');
insert into demo values(2,4,'R');
insert into demo values(2,4,'S');
insert into demo values(2,5,'T');
commit;
--■■■分析関数を使う方法■■■
select CLM1,CLM2,CLM3
from (select CLM1,CLM2,CLM3,
count(*) over(partition by CLM1,CLM2) as GroupCount
from demo)
where GroupCount >= 5
order by CLM1,CLM2,CLM3;
--■■■in述語を使う方法■■■
select CLM1,CLM2,CLM3
from demo
where (CLM1,CLM2) in(select CLM1,CLM2
from demo
group by CLM1,CLM2
having count(*) >= 5)
order by CLM1,CLM2,CLM3;