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
Data Cleaning and Validation
00:00
5 left

Data Cleaning and Validation

HardSQL · PostgreSQL

Problem

How do you approach data cleaning and validation when dealing with large, unstructured datasets?

Write a PostgreSQL query that standardizes raw usage fields, checks each record against the subscriber reference data, and identifies invalid records. Treat blank values, malformed dates, unsupported event types, negative usage, unknown subscribers, and inactive subscribers as validation failures.

Output

  1. Return one row per invalid usage event.
  2. Include event_id, cleaned subscriber and event fields, validation_status, and validation_reason.
  3. Order by event_id ascending.

Schema

raw_usage_events
ColumnTypeDescription
event_idPKINTUnique raw usage event identifier
raw_subscriber_idVARCHAR(30)Unstandardized subscriber identifier
raw_event_typeVARCHAR(30)Unstandardized usage event type
raw_event_dateVARCHAR(30)Event date stored as raw text
raw_usage_mbVARCHAR(30)Usage amount stored as raw text in megabytes
subscriber_accounts
ColumnTypeDescription
subscriber_idPKVARCHAR(30)Reference subscriber identifier
account_statusVARCHAR(20)Current subscriber account status
Tablesraw_usage_eventssubscriber_accounts
Interviewer

Your question is Data Cleaning and Validation. 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.