Duplicate Rows
Updated
Problem statement
A branch imported its customer contact list into the customer_contacts table, and part of the file was loaded more than once. The table has no key, so the same row can appear several times.
Write a query that finds the repeated rows. Two rows are copies of each other only when full_name, email and city are all equal; rows that share just a name or an email are different rows.
Return each row that appears two or more times exactly once, with its three columns and a fourth column copies: the number of times that row appears in the table. Rows that appear only once are left out. Return the rows in any order.
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.
customer_contacts
Imported contact rows; the same row can appear more than once.
| Column | Type | Nullable | Description |
|---|---|---|---|
| full_name | Text | No | Customer's name. |
| Text | No | Customer's email address. | |
| city | Text | No | Customer's city. |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| full_name | Text | No | — |
| Text | No | — | |
| city | Text | No | — |
| copies | Integer | No | — |
Row order: any order is accepted. Numeric tolerance: 0.
Constraints
- The
customer_contactstable has between1and1000rows. - No column is ever
NULL. full_namehas 1 to 40 characters,email3 to 60 andcity1 to 30, all printable ASCII with no leading or trailing spaces.emailis all lowercase, and no two values in the same column differ only in letter case.
More Bank of America Onsite Interview questions
- Centered Star PyramidONSITE INTERVIEW · Seen Nov 2025
- Employees Without a ManagerONSITE INTERVIEW · Seen Nov 2025
- Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2025
- N-th Fibonacci NumberONSITE INTERVIEW · Seen Nov 2025
- Reverse Each Word in a SentenceONSITE INTERVIEW · Seen Nov 2025
- Second Highest SalaryONSITE INTERVIEW · Seen Nov 2025
- Three Numbers That Add Up to a TargetONSITE INTERVIEW · Seen Apr 2025
- Factorial of a NumberONSITE INTERVIEW · Seen Oct 2023
- Palindrome String CheckONSITE INTERVIEW · Seen Sep 2023
- Second Largest Element in an ArrayONSITE INTERVIEW · Seen Jun 2023
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
- 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