Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
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 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
Build my plan
Cleaning a Messy Dataset
00:00
5 left

Cleaning a Messy Dataset

MediumSQL · PostgreSQL

Problem

How would you approach cleaning a messy dataset?

For this SQL exercise, treat a row as clean when its required fields are present, its event name is not blank, and its revenue is nonnegative. Write a query that returns only clean records and removes surrounding whitespace from event names.

Output

  1. One row per clean event with columns event_id, player_id, event_name, event_date, and revenue_usd
  2. Exclude rows with missing required values, blank event names, or negative revenue
  3. Order by event_date ascending, then event_id ascending

Schema

game_events
ColumnTypeDescription
event_idPKINTUnique identifier for the raw event record
player_idINTIdentifier of the player associated with the event
event_nameVARCHAR(100)Name of the recorded game event
event_dateDATEDate on which the event occurred
revenue_usdNUMERIC(10,2)Revenue associated with the event in US dollars
Tablesgame_events
Interviewer

Your question is Cleaning a Messy Dataset. Start with the requirements and the one table 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.