Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Data Quality Checks

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

Your question is SQL Data Quality Checks. 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

Sigmoid's transaction pipelines need a repeatable SQL audit before data is loaded into downstream analytics surfaces. Write a PostgreSQL query that returns every transaction with one or more data quality issues.

Requirements

  1. Flag missing customer_id, merchant_id, amount, currency, or status, treating empty customer IDs as missing.
  2. Flag duplicate business keys defined by (merchant_id, external_transaction_id).
  3. Flag non-positive amounts, transactions after 2025-01-31, and transaction rows whose merchant does not exist.
  4. Return one row per affected transaction with a comma-separated, alphabetically ordered list of issue types, sorted by transaction_id.

Schema

transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction row identifier
merchant_idINTReferenced merchant identifier
external_transaction_idVARCHAR(30)Source-system transaction key
customer_idVARCHAR(30)Customer identifier
amountNUMERIC(12,2)Transaction amount
currencyVARCHAR(3)Currency code
transaction_dateDATETransaction date
statusVARCHAR(20)Processing status
merchants
ColumnTypeDescription
merchant_idPKINTMerchant identifier
merchant_nameVARCHAR(100)Merchant display name
Tablestransactionsmerchants
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results