SQL: Delete Duplicates
Medium
SQL — DML
SQL
DELETE
Subquery
Delete duplicate emails keeping lowest ID.
Constraints
Write standard SQL (MySQL 8.0 compatible).
Examples
Example 1:
Input: 1 [email protected]
2 [email protected]
3 [email protected]
Output:
Example 2:
Input: 1 [email protected]
2 [email protected]
3 [email protected]
Output:
Hints
DELETE with self-join or subquery.
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console