Find Duplicate Employee Records
Updated
Problem statement
The table employees holds employee records. Because of a data entry bug, the same record was sometimes stored more than once: two rows are copies of the same record when they have the same emp_id and the same name. Each stored row has its own row_id.
Return every emp_id and name pair that is stored more than once. List each such pair once, with the columns emp_id and name, sorted by emp_id and then by name, both from smallest to largest.
Rows with the same name but a different ID, or the same ID but a different name, are not copies of each other.
| Column | Meaning |
|---|---|
row_id | Unique number of the stored row |
emp_id | Employee ID |
name | Employee name |
Table schema
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
employees
Employee records. The same employee record (emp_id and name) may have been stored more than once.
| Column | Type | Nullable | Description |
|---|---|---|---|
| row_idPK | Integer | No | Unique number of the stored row. |
| emp_id | Integer | No | Employee ID. |
| name | Text | No | Employee name. |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| emp_id | Integer | No | — |
| name | Text | No | — |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
employeeshas at most500rows.row_idis unique;row_idandemp_idare integers between1and10^6.namehas1to30English letters. Two names in the table never differ only in upper or lower case.- No column contains
NULL.
More Infosys Onsite Interview questions
- Minimum Coins for a TargetONSITE INTERVIEW · Seen Nov 2026
- Delete Duplicate Employee RecordsONSITE INTERVIEW · Seen Nov 2026
- Minimum Insertion Steps to Make a String PalindromeONSITE INTERVIEW · Seen Nov 2026
- Maximize the Even-Odd Index Product GapONSITE INTERVIEW · Seen Oct 2026
- Minimum Nonadjacent Flips for an Alternating Binary StringONSITE INTERVIEW · Seen Oct 2026
- Tenth-Highest Distinct SalaryONSITE INTERVIEW · Seen Oct 2026
- Assign Cookies With Matching ParityONSITE INTERVIEW · Seen Sep 2026
- Count Equal Code Pairs Within Distance KONSITE INTERVIEW · Seen Sep 2026
- Daily Successful Transactions Per DepartmentONSITE INTERVIEW · Seen Sep 2026
- Detect Substring In Any RotationONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Records Created or Updated in a Time WindowPelatro · ONSITE INTERVIEW
- Top Ten Employee SalariesSolytics Partners · ONSITE INTERVIEW
- Latest New JobSphere · ONSITE INTERVIEW
- Employees Whose Manager Left the CompanyZS · ONSITE INTERVIEWZS interview questions
- Employees Above Average SalaryJP Morgan Chase · ONSITE INTERVIEWJP Morgan Chase interview questions
- Retrieve Every Student RecordLSEG · ONSITE INTERVIEWLSEG interview questions
- Combine Winner and Loser NamesAmazon · ONSITE INTERVIEW
- Conditionally Insert or Update RecordsKlaviyo · ONSITE INTERVIEWKlaviyo interview questions
- Employees with Matching DepartmentsAMD · ONSITE INTERVIEWAMD interview questions
- New-User Devices That Opened an AppMicrosoft · ONSITE INTERVIEWMicrosoft interview questions