select * from t where name in (select name from t group by name having count(name)>=2 )
create table test( cid int,seqid varchar2(100) ); / insert into test select 1,'a' from dual union all select 2,'a' from dual union all select 3,'b' from dual union all select 4,'c' from dual union all select 5,'c' from dual union all select 6,'d' from dual; --执行查询 select * from test where seqid in (select seqid from test group by seqid having count(*)>1) --执行结果 1 a 2 a 4 c 5 c
select a.* from t a ,t b where a.id<>b.id and a.name=b.name(要求ID是唯一的)或用以下的方法select name,count(*) from t group by name having count(*) >1
select ename from emp group by ename having count(ename)>1
to : wwwzjb(zjb) select a.* from t a ,t b where a.id<>b.id and a.name=b.name(要求ID是唯一的) 这个方法不对
where name
in (select name
from t
group by name
having count(name)>=2 )
/
insert into test
select 1,'a' from dual union all
select 2,'a' from dual union all
select 3,'b' from dual union all
select 4,'c' from dual union all
select 5,'c' from dual union all
select 6,'d' from dual;
--执行查询
select * from test where seqid in
(select seqid from test group by seqid having count(*)>1)
--执行结果
1 a
2 a
4 c
5 c
group by name
having count(*) >1
group by ename
having count(ename)>1
select a.* from t a ,t b where a.id<>b.id and a.name=b.name(要求ID是唯一的)
这个方法不对