Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Deduplication with Windowing
00:00
5 left

Deduplication with Windowing

MediumSQL · PostgreSQL

Problem

Explain how you would perform complex data deduplication across large dataset partitions using windowing functions like ROW_NUMBER or DENSE_RANK.

Use the supplied ingestion records and source metadata. Return one surviving record per business key, suppressing keys whose latest record is marked deleted.

Output

  1. One row per surviving customer_ref, event_date, and event_type combination
  2. Include the selected record fields, source name, and its deduplication rank
  3. Order by customer_ref, event_date, and event_type, with nulls last

Schema

ingestion_records
ColumnTypeDescription
record_idPKINTUnique ingestion record identifier
customer_refVARCHAR(30)Customer reference used in the business key
event_dateDATEBusiness date of the event
event_typeVARCHAR(30)Business event type
source_system_idINTIdentifier of the source system
source_record_idVARCHAR(40)Record identifier from the source system
payloadJSONBRaw event payload
updated_atTIMESTAMPSource update timestamp
ingested_atTIMESTAMPTimestamp when the record entered the platform
quality_scoreDECIMAL(5,2)Data quality score assigned during ingestion
is_deletedBOOLEANWhether the record represents a deletion
partition_nameVARCHAR(30)Physical ingestion partition
source_systems
ColumnTypeDescription
source_system_idPKINTUnique source system identifier
source_nameVARCHAR(50)Source system name
source_priorityINTPreferred-source priority used as a tie-breaker
Tablesingestion_recordssource_systems
Interviewer

Your question is Deduplication with Windowing. Start with the requirements and the two tables in the Question tab.

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.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.