Data Cleaning and Quality Validation in SQL Questions
Handle NULL values, duplicates, and data type issues within queries. Implement data validation checks (row counts, value distributions, date ranges). Practice identifying and documenting data quality issues that impact analysis reliability.
EasyTechnical
71 practiced
Describe with SQL DDL how to add CHECK constraints to a 'payments' table to ensure amount >= 0 and currency IN ('USD','EUR'). Explain how to add those constraints to a table that already has violating rows and how to deploy safely in production databases (PostgreSQL).
HardTechnical
67 practiced
Design SQL to compute a data quality scorecard per table and per column combining metrics: completeness (1 - null_pct), uniqueness (1 - dup_rate), accuracy (1 - error_rate), and timeliness (normalized freshness). Provide sample weightings and SQL that produces a composite score between 0 and 100.
MediumTechnical
94 practiced
You must estimate the duplicate rate on a 100B-row partitioned 'clicks' table for keys (user_id, session_id) without scanning everything. Describe a statistically sound sampling strategy, write the SQL to obtain the sample, compute duplicate rate and 95% confidence interval, and explain how you'd stratify by partition/day.
MediumTechnical
76 practiced
The 'user_profiles' table has a 'gender' column with inconsistent values: 'M', 'Male', 'male', 'FEMALE', 'f', etc. Write SQL to produce a mapping of observed values to canonical values and a SELECT that normalizes gender using that mapping. Explain where you would store the mapping for maintainability.
MediumTechnical
65 practiced
A frequently run analytic query repeatedly casts a varchar column 'user_id_str' to INT many times, causing CPU overhead. Propose a SQL rewrite and a long-term schema change to avoid repeated casting. Provide before-and-after SQL snippets and discuss trade-offs.
Unlock Full Question Bank
Get access to hundreds of Data Cleaning and Quality Validation in SQL interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.