Skip to content
Advertisement

Filter duplicate records and retain 1 record

I was able to get the duplicate records and I wanted to retain 1 record per item barcode based on the createdate (oldest)

sample script of getting the duplicate records:

output:


final output should be like this: (retain the items that has the oldest createdate from the 2 duplicate Barcodes)

Advertisement

Answer

I guess you need first record based on create date per barcode. If you are using MySQL version 8.0 or higher, You may use window function –

If you are using lower versions you may try below –

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement