select t.* from a t where exists(select 1 from (select xm,sfzhm from a group by xm, sfzhm having count(1) >= 2) m where m.xm = t.xm and m.sfzhm = t.sfzhm) order by t.xm , t.sfzhm
只有一条记录吧? 咋跑出两条记录来了? 这个可以用自连接吧
select * from table_name a,table_name b where a.xm = b.sfzhm
谢谢2楼,我要的就是这种结果,由于我刚学oracle,因此还请解释下这条语句, select 1 from (select xm,sfzhm from a group by xm, sfzhm having count(1) >= 2) m where m.xm = t.xm and m.sfzhm = t.sfzhm,这条语句有点复杂,请解释下,谢谢。 另外能否使查询速度更快点?