查询在oracle中查找重复记录

时间:2011-12-26 15:30:55

标签: oracle plsql

我有查询要查找重复记录:

select min(a.rowindex)rowindx, b.rowindex rowindx1 
from dedupinitial1 a,
dedupinitial1 b 
where a.rowindex < b.rowindex 
 and a.name = b.name
group by b.rowindex
order by 1;

但这给我的结果如下:

3   182161
3   121963
3   41619
3   219762
3   163808
3   122614
3   271
3   163809
3   81
4   75060
4   60086
4   109294
4   98135
4   98468
4   165069

但我想要像

这样的结果
3   182161
    3   121963
    3   41619
    3   219762
    3   163808
    3   122614
    3   271
    3   163809
    3   81
    3    3
    4   75060
    4   60086
    4   109294
    4   98135
    4   98468
    4   165069
    4    4

我的愿望结果还包括组中的3和4

1 个答案:

答案 0 :(得分:3)

这会有用吗?

select min(a.rowindex)rowindx, b.rowindex rowindx1 
from dedupinitial1 a,
dedupinitial1 b 
where a.rowindex <= b.rowindex 
 and a.name = b.name
group by b.rowindex
order by 1;