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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Start free
Identify Duplicate Missing and Differing Extract Rows
00:00
5 left

Identify Duplicate Missing and Differing Extract Rows

MediumSQL · PostgreSQL

Problem

How do you approach complex data sets in Excel to ensure accuracy?

Use the supplied excel_extract and system_records tables to identify extract rows that require review. Include records that are duplicated in the extract, missing from the system data, or have differing values. Treat two NULL values in the same field as equal.

Output

  1. One row per extract row requiring review, with row_id, record_id, nhs_number, and discrepancy_reason.
  2. Include duplicate, missing, or differing records only.
  3. Order by row_id ascending.

Output details

  • Define duplicates as record_id values appearing more than once in excel_extract.
  • Match extract and system records by record_id.
  • Compare nhs_number, extract_date, status, and amount; treat one NULL versus a non-NULL value as differing.
  • Use discrepancy reasons duplicate_excel_record, missing_system_record, and field_mismatch.
  • When both duplicate and missing apply, use duplicate_excel_record; missing_system_record; otherwise use the applicable single reason.

Schema

excel_extract
ColumnTypeDescription
row_idPKINTUnique row identifier from the Excel extract
record_idVARCHAR(20)Business record identifier, which may be duplicated in the extract
nhs_numberVARCHAR(10)NHS number recorded in the extract
extract_dateDATEDate associated with the extracted record
statusVARCHAR(20)Record status from the extract
amountNUMERIC(10,2)Recorded amount
system_records
ColumnTypeDescription
record_idPKVARCHAR(20)Unique system record identifier
nhs_numberVARCHAR(10)NHS number stored in the system
extract_dateDATEDate associated with the system record
statusVARCHAR(20)System record status
amountNUMERIC(10,2)System amount
Tablesexcel_extractsystem_records
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the two tables are in the Question tab.

Sign up free to run or submit. Log in
CodePostgreSQL
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 1
Run your query to see results here.