如何在oracle中查找具有不同Rowid的相似数据?

How to Find similar data with different Rowid in oracle?

我有一个 table 这样的:

X   Y
======
20  20
20  20
20  21
23  22
22  23
21  20

我需要在 X=Y 中找到那些 rowid 但它们的 rowid 不一样?就像第一行的 X 和第二行的 Y 一样,但它们在不同的行中。

您想要重复的行:

select *
from
 (
   select x, y, rowid, count(*) over (partition by x,y) as cnt
   from tab
   where x=y
 ) dt
where cnt > 1

请检查这是否有效

  select * from tab a where exists (select * from tab b where a.x=b.y and a.rowid!=b.rownid);

您可以通过多种方式完成,并且由于您提出了 rowid,这就是其中之一:

select * from yourtable tab1 join yourtable tab2 on tab1.x = tab2.y and tab1.rowid <> tab2.rowid