-1

I have duplicates like these in a table: enter image description here

I can select the duplicates, but I need to select only the ones marked in yellow, aka: the oldest of the duplicates. How could I filter those?

Ikzer
  • 527
  • 11
  • 29

1 Answers1

0

You can use ROW_NUMBER() window function to identify the oldest record, and then just select that:

SELECT *
FROM 
    (
        SELECT yt.*, ROW_NUMBER() OVER (PARTITION BY REFERENCE ORDER BY CREATION DATE ASC) as rn
        FROM yt
    )
WHERE rn = 1;
JNevill
  • 46,980
  • 4
  • 38
  • 63