InterviewStack.io LogoInterviewStack.io

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.

MediumTechnical
0 practiced
Given monthly counts per product_category for two months, write SQL to compute percent differences in distribution and perform a chi-square style test to flag significant distributional changes. Provide SQL that outputs category, count_month_a, count_month_b, percent_change, and chi_square_component.
MediumTechnical
0 practiced
Table 'raw_logs' has a string column ts_string that may appear in formats 'YYYY-MM-DD', 'MM/DD/YYYY', 'DD Mon YYYY', etc. Write SQL (BigQuery or PostgreSQL) that attempts multiple parses and returns rows that failed to parse to TIMESTAMP. Discuss ambiguous dates and how you would detect the prevalent format automatically.
MediumTechnical
0 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.
HardTechnical
0 practiced
Write a SQL query that deduplicates contact records according to hierarchical precedence: prefer verified_email=true, then phone_verified=true, then latest updated_at. The input is 'contacts' (contact_id, person_key, verified_email BOOL, phone_verified BOOL, updated_at TIMESTAMP). The query should return one canonical row per person_key.
EasyTechnical
0 practiced
For table 'events' with column 'event_type', write SQL to list the top 10 most frequent event_type values with their counts and percentage of total events. Explain how this helps triage data quality issues.

Unlock Full Question Bank

Get access to hundreds of Data Cleaning and Quality Validation in SQL interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.