Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
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.