FastPrepDelete Duplicate Employee Records
Problems/Delete Duplicate Employee Records

Delete Duplicate Employee Records

Infosys logoInfosys● EasyFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionConstraints

Problem statement

Source note: Reported in an Infosys full-time onsite interview. In the technical interview, after finding duplicate names and IDs with SQL, the candidate was asked to delete the duplicate records.

The report gives no table or rule for which copy to keep. Here, rows match when both ID and name match, the copy with the smallest row_id is kept, and the remaining rows are checked through a read-only query instead of a DELETE statement.

Our version is about 70% the same as the reported question.

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.

Delete the duplicates: for each record, keep only the copy with the smallest row_id and remove the others. Rows that are not repeated stay as they are.

Your answer is checked on the rows that remain. Write one read-only SELECT query (a CTE is fine) in SQL, or return a DataFrame in Pandas, that returns exactly the remaining rows with the columns row_id, emp_id, and name, sorted by row_id from smallest to largest. The input table itself is not changed.

employees
ColumnMeaning
row_idUnique number of the stored row
emp_idEmployee ID
nameEmployee name

Table schema

MySQLPostgreSQLPandas

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.

ColumnTypeNullableDescription
row_idPKIntegerNoUnique number of the stored row.
emp_idIntegerNoEmployee ID.
nameTextNoEmployee name.

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
row_idIntegerNo—
emp_idIntegerNo—
nameTextNo—

Row order: must match exactly. Numeric tolerance: 0.

Constraints

  • employees has at most 500 rows.
  • row_id is unique; row_id and emp_id are integers between 1 and 10^6.
  • name has 1 to 30 English 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
  • Find 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
All Infosys interview questionsSee Infosys hiring insights