Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
SQL Data Validation Checks
00:00
5 left

SQL Data Validation Checks

MediumSQL · PostgreSQL

Problem

How would you implement a data validation check in SQL?

Validate each record for a nonblank record key, an allowed status, an event date in 2025, and a non-null amount that is zero or greater. Return every record, including valid records, and identify all applicable validation issues.

Output

  1. One row per record with record_id, record_key, validation_status, and validation_errors.
  2. Set validation_status to VALID or INVALID; combine multiple issues in validation_errors.
  3. Order by record_id ascending.

Schema

validation_records
ColumnTypeDescription
record_idPKINTUnique identifier for the record
record_keyVARCHAR(40)Business key that should be present and nonblank
status_codeVARCHAR(20)Status that must exist in the allowed-status reference table
event_dateDATEDate required to fall within calendar year 2025
amountNUMERIC(10,2)Value that must be non-null and non-negative
allowed_statuses
ColumnTypeDescription
status_codePKVARCHAR(20)Recognized status code
status_labelVARCHAR(60)Description of the recognized status
Tablesvalidation_recordsallowed_statuses
Interviewer

Your question is SQL Data Validation Checks. Start with the requirements and the two tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.