看看 我要的效果怎么写 sql ?
数据字段
id name
1 a
2 a
3 b
4 c
5 c
6 d
我想把表里的 name 重复的项查出来 怎么写啊??
------解决方案--------------------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