Delete Duplicate Records in Employees Table

Delete duplicate records while keeping the most recently created record.

sql

DELETE e1 FROM employees e1 INNER JOIN employees e2 WHERE e1.id < e2.id AND e1.email = e2.email;

This query removes duplicate rows from the "employees" table based on the "email" column, retaining only the record with the highest "id" value, which represents the most recently created entry.

PromptDB can make mistakes. Please double-check responses.