InterviewStack.io LogoInterviewStack.io

SQL-Based Data Validation and Anomaly Detection Questions

Techniques for validating data quality and detecting anomalies using SQL: identifying nulls and missing values, finding duplicates and orphan records, range checks, sanity checks across aggregates, distribution checks, outlier detection heuristics, reconciliation queries across systems, and building SQL based alerts and integrity checks. Includes strategies for writing repeatable validation queries, comparing row counts and sums across pipelines, and documenting assumptions for investigative analysis.

EasyTechnical
51 practiced
Given the following table schema for an OLAP table:
orders(order_id BIGINT PK, customer_id BIGINT, order_date DATE, amount DECIMAL(10,2), status VARCHAR)
Write a single SQL query (ANSI SQL) that identifies rows where any of the critical columns (order_id, customer_id, order_date, amount) are NULL and returns the column(s) that are NULL per row along with a row_count.
HardSystem Design
51 practiced
Design a reconciliation pipeline that automatically compares row counts and numeric aggregates across three ETL stages (source → staging → warehouse), captures discrepancies, and attempts automated root-cause identification using lineage metadata. Outline the components, data model, and algorithm for automated root-cause hints.
HardSystem Design
25 practiced
You need to detect anomalies in streaming metrics with tight latency constraints (sub-10s detection). Architect a streaming solution using Flink/Beam/ksqlDB that performs SQL-like checks, describing state management, checkpointing, fault-tolerance, and how alerts are emitted without duplicating or losing events.
MediumTechnical
31 practiced
Design a set of SQL checks to verify referential integrity for denormalized analytics tables (e.g., fact tables referencing dimension keys). Include checks for missing keys, stale foreign keys, and surrogate key drift. Explain how you'd schedule and surface failures.
HardTechnical
27 practiced
Explain how to implement a z-score or exponentially weighted moving average (EWMA) anomaly detector using only SQL primitives for a time-series metric like daily_revenue. Provide example queries or window-function sketches and explain limitations.

Unlock Full Question Bank

Get access to hundreds of SQL-Based Data Validation and Anomaly Detection interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.