FastPrepRemove Duplicate Table Rows
Problems/Remove Duplicate Table Rows

Remove Duplicate Table Rows

JP Morgan Chase logoJP Morgan Chase● EasyINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionConstraints

Problem statement

Source note: Reported in a JP Morgan Chase intern onsite interview. The report asks for a SQL DELETE query to remove duplicates. In this task we grade the rows that should remain, through a read-only query or a returned DataFrame. DELETE syntax and changing the table are not graded. We chose the schema, the duplicate key, which row survives, the limits and the examples. Our version is about 75% the same as the reported task.

The table items has a unique integer row_id and a non-null integer value in each row. Rows belong to the same duplicate group when their value fields are equal, even though their IDs differ.

Return the complete rows that would remain after removing duplicates: keep the row with the smallest row_id for each distinct value. Return the columns row_id and value, ordered by row_id ascending.

Your answer is the set of rows that remain. In SQL, submit one read-only SELECT query or read-only CTE. In Pandas, return a DataFrame. Do not change the input table.

items
ColumnMeaning
row_idUnique row identifier
valueInteger used to identify duplicate groups

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.

items

Practice input table; equal value fields define duplicates.

ColumnTypeNullableDescription
row_idPKIntegerNoUnique row identifier.
valueIntegerNoRows with the same value belong to one duplicate group.

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
row_idIntegerNoUnique row identifier.
valueIntegerNoRows with the same value belong to one duplicate group.

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

Constraints

  • For this exercise, assume 0 <= number of input rows <= 1000.
  • 1 <= row_id <= 1000000, and every row_id is unique within the input table.
  • -1000000 <= value <= 1000000.
  • Neither column contains NULL.

More JP Morgan Chase Onsite Interview questions

  • LFU CacheONSITE INTERVIEW · Seen Nov 2026
  • LRU CacheONSITE INTERVIEW · Seen Nov 2026
  • Employees Above Average SalaryONSITE INTERVIEW · Seen Sep 2026
  • Highest-Earning Employees By DepartmentONSITE INTERVIEW · Seen Sep 2026
  • K Largest Integers in Descending OrderONSITE INTERVIEW · Seen Aug 2026
  • Tile a Three-Row Board with DominoesONSITE INTERVIEW · Seen Jan 2026
  • Two SumONSITE INTERVIEW · Seen Nov 2025
  • Intersection of Two ListsONSITE INTERVIEW · Seen Jan 2025
  • Maximum Subarray SumONSITE INTERVIEW · Seen Jan 2025
  • Fibonacci NumberONSITE INTERVIEW · Seen Nov 2024

Similar questions at other companies

  • Delete Duplicate Employee RecordsInfosys · ONSITE INTERVIEWInfosys interview questions
  • 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
  • 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

Interview reports that mention this question

  • JPMorgan Tech Intern HackerRank OA: 11 Experiences (Part 3 of 5)

JP Morgan Chase interview experiences

  • JPMorgan Quant Stats Superdays: 3 Experiences (Part 3 of 3)
  • JPMorgan Quant Modeling Superdays: 7 Experiences (Part 2 of 3)
  • JPMorgan Quant Intern Superday: 19 Experiences (Part 1 of 3)
  • JP Morgan Chase Data and AI Intern Superday: 11 Experiences
  • JPMorgan Code for Good India 2024: 6 Experiences (Part 5 of 5)
All JP Morgan Chase interview questionsSee JP Morgan Chase hiring insights