oracle中查詢重複數據

查詢結果集中多個字段相同:

select  * from 表 a where (a.Id,a.seq) in(select Id,seq from 表 group by Id,seq having  count(*) > 1)

例子:

with res as 
(
 SELECT '1' id, '小明' mc, '15' age from dual 
 union all 
 SELECT '2' id, '小明2' mc, '16' age from dual 
 union all 
 SELECT '3' id, '小明' mc, '15' age from dual  
)
 
select  * from res a where (a.mc,a.age) in(select mc,age from res group by mc,age having 
count(*) > 1)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章