Sobes.tech
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:

  1. Count how many times each email appears in the table.
  2. Output a list of emails where the number of occurrences exceeds one.
  3. 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)
);