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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
Cleaning Dates and Missing Values
00:00
5 left

Cleaning Dates and Missing Values

MediumSQL · PostgreSQL

Problem

How would you approach cleaning a dataset with inconsistent date formats and missing values?

Write a PostgreSQL query that standardizes recognized date formats, identifies missing and invalid dates, replaces missing numeric values with zero, and preserves records without a matching reference category.

Output

  1. One row per intake record with record_id, source_system, cleaned_date, date_status, cleaned_value, and category_name.
  2. Invalid or missing dates must produce a NULL cleaned_date; missing numeric values must produce zero; unmatched categories must be labeled Unclassified.
  3. Sort by record_id ascending.

Schema

raw_intake_records
ColumnTypeDescription
record_idPKINTUnique intake record identifier
source_systemVARCHAR(50)System that supplied the record
raw_dateVARCHAR(30)Date value in an unstandardized text format
raw_valueDECIMAL(10,2)Numeric value that may be missing
category_codeVARCHAR(10)Optional reference category code
category_reference
ColumnTypeDescription
category_codePKVARCHAR(10)Reference category code
category_nameVARCHAR(100)Readable category label
Tablesraw_intake_recordscategory_reference
Interviewer

Your question is Cleaning Dates and Missing Values. 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.