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.
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?
A reconciliation shows that row COUNTS match between a source and target table, but the SUMS differ significantly. Provide a prioritized set of SQL steps to isolate whether the mismatch is caused by currency conversion, late-arriving records, rounding, or a transformation bug, stating the expected indicator for each candidate cause.
After an instrumentation or ETL change, you discover a specific cohort or segment has been silently undercounted (or rows silently dropped) for some time, while the aggregate metrics looked normal enough not to trigger existing alerts. Describe how you would quantify the size and scope of the bias, what you would do to remediate it, and what you would add to your monitoring so a similar defect doesn't go undetected again.
Write a query that profiles a table column by column: for each column, return the total row count, null count, and null percentage. Explain the assumptions you make about empty strings and whitespace-only values counting as 'missing', and how your query would need to change to run efficiently across dozens or hundreds of wide tables.
A numeric column is stored as text and contains a mix of clean numbers and garbage: currency symbols, thousands separators, parentheses for negatives, and different locale conventions (for example, '$1,234.56' versus '1.234,56'). Write SQL that produces a cleaned numeric column plus an error flag for rows that cannot be safely cast, and explain how you would detect which locale or format convention a given row is using.
Unlock Full Question Bank
Get access to all SQL-Based Data Cleaning and Anomaly Detection interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.