InterviewStack.io LogoInterviewStack.io

SQL-Based Data Cleaning and Anomaly Detection Questions

Using SQL to profile, clean, and validate data: detecting duplicates, nulls, outliers, and referential-integrity breaks; writing production-safe diagnostic queries; and root-cause debugging of missing or incorrect data. Covers anomaly-detection queries and data cleaning for analytics. The hands-on SQL data-quality skill.

EasyTechnical
31 practiced

In your own words, what is the difference between 'data validation' and 'anomaly detection' in an analytics pipeline? Describe the kinds of issues each is meant to catch (for example, schema drift and missing values versus statistical outliers), the metrics you would use to measure how well each is working, and give an example of when you would reach for one rather than the other in production.

EasyTechnical
32 practiced

What is the difference between an 'outlier' and an 'anomaly' in a data-quality context? Give an example of a legitimate outlier that should be kept in the data for modeling or reporting, and an example of an anomaly that indicates a genuine data-quality issue and should be quarantined or removed. What instrumentation failure modes (clock resets, sentinel defaults, timestamp misalignment) commonly produce the second kind, and how would you triage between the two quickly?

EasyTechnical
25 practiced

Compare three strategies for deduplicating records: an exact-key approach (ROW_NUMBER/GROUP BY on an exact match), a deterministic multi-field match (e.g. matching on a normalized combination of fields), and a fuzzy/probabilistic match (similarity scoring across near-matching fields). For each, describe its strengths, weaknesses, and performance characteristics, and explain which one you would keep as canonical (earliest, latest, or a merge of fields) and why.

EasyTechnical
33 practiced

Explain z-score based outlier detection: how it's computed, what assumptions it relies on (roughly normal, unimodal data), and when it breaks down (skewed or multimodal real-world distributions). Give at least two reasons you might prefer an IQR-based approach instead, and name at least one alternative technique for heavy-tailed data.

EasyTechnical
31 practiced

Explain how SQL evaluates NULL in comparisons, boolean expressions, and aggregate functions. Why does col = NULL never match, and why do you need IS NULL / IS NOT NULL instead? Show how COALESCE and NULLIF are used to substitute or convert sentinel values, and how COUNT(*), COUNT(column), SUM, and AVG each treat NULLs differently. Also address the related design question: when should missing text be stored as NULL versus an empty string, and why does that choice matter for downstream validation checks?

Unlock Full Question Bank

Get access to all 6 SQL-Based Data Cleaning and Anomaly Detection interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.