Skip to content
Advertisement

How to delete rows that have duplicate column combination

I need to delete some rows that have the same column combination (except ID). The row that should be kept is the one that has the maximum reference date

So, after the query the table should be like this

I know that the query below will return the table I want, but I don’t know how to delete the “duplicate” entries and leave only the one with the maximum date.

Advertisement

Answer

You can try to use delete JOIN

or use EXISTS subquery.

sqlfiddle

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