select a.* from 一个表 a,(select 某字段 from 一个表 group by 某字段 having count(*)>1) as b
where a.某字段=b.某字段
select columnname
from tablename
group by columnname
having count(*) > 1
SQL> select b.id,b.doctime from (select id,count(*) sumnum from test1 group by i
d) a,test1 b where a.id=b.id and a.sumnum>1;
ID DOCTIME
---------- ---------
1 01-JUL-02
1 01-MAY-02
1 20-AUG-02
1 01-JUL-02
1 01-SEP-02
Elapsed: 00:00:00.40
select id,count(*) from tablename group by id having count(*) > 1
请问我想取出(oracle)数据库中某一字段下含有重复值得记录,就是检查出有重复值的项,例如 (人员信息表,我想查询出含有相同身份证号的人,在web页面展示查询结果,由于数据量比较大还要考虑效率)sql语句如何写?
如果只查身份证可以:
select 身份证号,count(*) from 人员信息表
group by 身份证号 having count(*)>1
查信息表全部的话:
select * from 人员信息表
where
身份证号=(select 身份证号 from 人员信息表
group by 身份证号 having count(*)>1)