Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL for Duplicate Records

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

Your question is SQL for 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

Principal Financial Group uses claims data for operational reporting and quality checks. Write a PostgreSQL query to identify duplicate non-void claims received during 2025.

A claim is considered a duplicate when multiple records share the same member_id, claim_date, provider_code, and claim_amount. Exclude rows with a null provider_code, but retain claims whose claim_status is null. Include member details when available, without removing duplicate claims for an unmatched member.

Requirements

  1. Group claims by the four business-key columns and retain only groups containing at least two records.
  2. Return one row per duplicate business-key group, including the duplicate count.
  3. Use a LEFT JOIN to add the member name, and sort by claim date and member ID.

Schema

claims
ColumnTypeDescription
claim_idPKINTEGERUnique claim record identifier
member_idINTEGERPrincipal member identifier
claim_dateDATEDate the claim was submitted
provider_codeVARCHAR(20)Billing provider code
claim_amountNUMERIC(10,2)Submitted claim amount
claim_statusVARCHAR(20)Claim processing status
members
ColumnTypeDescription
member_idPKINTEGERUnique Principal member identifier
member_nameVARCHAR(100)Member's full name
plan_nameVARCHAR(80)Principal insurance plan name
Tablesclaimsmembers
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results