I have a table that contains some duplicate values like the one below. Is there a way to remove the duplicate value even if the row data contains different values?

If only the duplicate row data are all the same value, I can use the group by. The problem is that it contains different values.
Thanks so much for any possible help.


Deepak TewatiaRank #143 · 15.9K reputationPosted Jan 28, 2023, 10:55 AM EST
Hi Hold,
To delete duplicate entries from your SQL table, please use the following SQL statement and replace “Table_Name” with the actual name of your table.
WITH CTE AS ( SELECT *, ROW_NUMBER() OVER (PARTITION BY ReferenceNo ORDER BY ReferenceNo) AS row_num FROM Table_Name ) DELETE FROM CTE WHERE row_num > 1;Note:- It's always a good idea to take a backup of the table or the database before performing any delete operation.