Search code examples
sqldatabaseoracle-databaserowid

How to Find similar data with different Rowid in oracle?


I have a table like this:

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

I need to find those rowid's where X=Y but their rowid is not the same? Like 1st row's X and 2nd row's Y is the same but they are in different rows.


Solution

  • you can do it many ways, and since you brought the rowid up, this is one of them:

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