can i select all rows where two columns have the same value?

The simplest method are probably window functions:

select t.*
from (select t.*,
             count(*) over (partition by id, version) as cnt
      from t
     ) t
where cnt >= 2;

If you have an index on (id, version) (or (version, id)), then the database engine should be able to take advantage of that.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top