Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Find Duplicate Records

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

Your question is Find Duplicate Records. 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

PenFed Credit Union needs to identify duplicate records in its application intake pipeline before downstream reporting and servicing processes consume them. Treat records with the same member, product, application date, and requested amount as duplicates. A NULL requested amount should match another NULL requested amount.

Write a PostgreSQL query that returns every record belonging to a duplicate group and enriches it with the member name when available.

Requirements

  1. Use member_id, product_code, application_date, and requested_amount as the duplicate key. Do not use application_id or application_status.
  2. Return the original application fields, the member name, and the number of records in the duplicate group.
  3. Include applications whose member has no matching row in penfed_members, using Unknown member for the missing name.
  4. Sort by member_id, product code, application date, and application ID.

Schema

penfed_application_intake
ColumnTypeDescription
application_idPKINTEGERUnique application record identifier
member_idINTEGERPenFed member identifier
product_codeVARCHAR(20)Requested financial product code
application_dateDATEDate the application was received
requested_amountNUMERIC(12,2)Requested loan or credit amount
application_statusVARCHAR(20)Current application intake status
penfed_members
ColumnTypeDescription
member_idPKINTEGERUnique PenFed member identifier
member_nameVARCHAR(100)Member display name
Tablespenfed_application_intakepenfed_members
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results