查詢結果集中多個字段相同:
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)