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
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
Get started
SQL Duplicate or Missing Records
00:00
5 left

SQL Duplicate or Missing Records

MediumSQL · PostgreSQL

Problem

Write a SQL query to find duplicate or missing records in an operations dataset.

Use the expected_operations and operation_records tables. A duplicate is an operation identifier appearing more than once in operation_records. A missing record is an expected operation with no corresponding record.

Output

  1. Return one row per issue with issue_type, operation_id, and record_count.
  2. Use DUPLICATE or MISSING for issue_type; use zero for missing records.
  3. Order by issue_type, then operation_id.

Schema

expected_operations
ColumnTypeDescription
operation_idPKINTIdentifier of an operation expected in the dataset
operation_nameVARCHAR(100)Name of the expected operation
required_dateDATEDate on which the operation is expected
priorityVARCHAR(20)Operational priority
operation_records
ColumnTypeDescription
record_idPKINTUnique submitted record identifier
operation_idINTReferenced operation identifier
recorded_dateDATEDate the operation was recorded
statusVARCHAR(20)Submitted operation status
source_systemVARCHAR(30)System that submitted the record
Tablesexpected_operationsoperation_records
Interviewer

Your question is SQL Duplicate or Missing Records. 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.