Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Identify Duplicate Records in SQL

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

Your question is Identify Duplicate Records in SQL. Start with the requirements and the one table 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

Bain & Company is validating client-contact intake records before loading them into its centralized analytics environment. Duplicate email addresses may represent repeated submissions and should be reviewed.

Write a PostgreSQL query to identify email addresses that occur more than once in the client_contacts table.

Requirements

  1. Exclude rows where email is NULL, because a missing email cannot identify a duplicate contact.
  2. Return each duplicated email and the number of records using it, ordered by duplicate count descending and email ascending.

Schema

client_contacts
ColumnTypeDescription
contact_idPKINTUnique contact-record identifier
contact_nameVARCHAR(100)Contact's name
emailVARCHAR(255)Contact email address used for duplicate detection
source_systemVARCHAR(50)System that submitted the record
Tablesclient_contacts
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results