Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Find Duplicate Rows in SQL

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Find Duplicate Rows in SQL. Start with the requirements and the two tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

EPAM Systems uses several intake channels, including the EPAM Client Portal and EPAM CRM, to collect client contact records. Data quality analysts need to identify repeated contact values among records received from active source systems.

Write a PostgreSQL query that returns duplicate combinations of email and phone from active source systems.

Requirements

  1. Join client_contacts to source_systems using source_system_id.
  2. Include only source systems where is_active is true.
  3. Group by email and phone, return only groups occurring more than once, and include the duplicate count.
  4. Order by duplicate count descending, then email ascending, with NULL emails last and NULL phones first.

Schema

client_contacts
ColumnTypeDescription
contact_idPKINTUnique contact record identifier
emailVARCHAR(255)Client email address
phoneVARCHAR(30)Client phone number
source_system_idINTReferences the intake source system
created_atDATEDate the contact record was created
source_systems
ColumnTypeDescription
source_system_idPKINTUnique source system identifier
source_system_nameVARCHAR(100)Name of the intake system
is_activeBOOLEANWhether the source system is active
Tablesclient_contactssource_systems
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results