Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Reconcile Two Tables SQL
00:00
5 left

Reconcile Two Tables SQL

MediumSQL · PostgreSQL

Problem

Write a SQL query to reconcile two tables and identify rows that are missing or mismatched between them.

Compare records with the same record_id across source_records and target_records. Return only records that exist in one table but not the other, or have different values in any compared column.

Output

  1. One row per missing or mismatched record_id
  2. Include record_id, both tables' status, amount, and update date values, plus discrepancy_type
  3. Sort by record_id ascending

Schema

source_records
ColumnTypeDescription
record_idPKINTUnique record identifier
record_statusVARCHAR(30)Current source record status
amountNUMERIC(10,2)Source record amount
updated_atDATEDate the source record was updated
target_records
ColumnTypeDescription
record_idPKINTUnique record identifier
record_statusVARCHAR(30)Current target record status
amountNUMERIC(10,2)Target record amount
updated_atDATEDate the target record was updated
Tablessource_recordstarget_records
Interviewer

Your question is Reconcile Two Tables SQL. 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.