Each row of the Employees table is one employee record. A row is a duplicate if another row has the same name and email but a smaller id. Within each (name, email) group, the row with the smallest id is kept. Return the id, name and email of every duplicate row, ordered by id ascending.
Input Table(s)
Table: Employees
| Column | Type | Meaning |
|---|
| id | INT | Row identifier |
| name | VARCHAR(100) | Employee name |
| email | VARCHAR(100) | Employee email address |
Primary key: id. There is no other key or unique constraint, so name and email may repeat across rows.
Output Contract
-
Columns, in this order:
id
,
name
,
email
, copied unchanged from the duplicate row.
-
One output row per duplicate record. A row that is kept (the smallest
id
of its group) does not appear.
-
Order by
id
ascending.
id
is unique, so the order is fully determined.
-
No rounding applies.
Example
Input Employees:
Expected output:
Rows 3 and 5 repeat the (name, email) pairs of rows 1 and 2, which have smaller ids and are kept. Row 4 is the only Charlie row. Row 6 writes the name in lowercase, so it forms its own group and is kept.
Constraints and Clarifications
-
The table has 1 to 10,000 rows.
-
id
is unique.
name
and
email
may repeat across rows.
-
Comparisons on
name
and
email
are exact and case-sensitive:
Alice
and
alice
are different names. No trimming or other normalization is applied.
-
A group with three or more rows returns every row except the one with the smallest
id
.
-
name
and
email
are not declared NOT NULL. A NULL matches only another NULL in the same column, the way
GROUP BY
treats it, so two rows with a NULL
name
and the same
email
form one group.
-
If no row is a duplicate, the result is empty.