Intern — Middle
Detection and removal of duplicate email addresses
livecode
Task condition
The Person table stores users' email addresses. There may be cases where the same email appears multiple times. The requirements are:
- Count how many times each email appears in the table.
- Output a list of emails where the number of occurrences exceeds one.
- Remove all duplicates from the table, leaving only one record for each unique email.
Example input data
+----+-------------------+
| id | email |
+----+-------------------+
| 1 | john@example.com |
| 2 | bob@example.com |
| 3 | john@example.com |
+----+-------------------+
Expected result
+----+-------------------+
| id | email |
+----+-------------------+
| 1 | john@example.com |
| 2 | bob@example.com |
+----+-------------------+
CREATE TABLE Person (
id INT PRIMARY KEY,
email VARCHAR(255)
);