Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Data Manipulation Gotchas
00:00
5 left

Data Manipulation Gotchas

MediumSQL · PostgreSQL

Problem

Tell me about a time you handled tricky data manipulation issues, including edge cases and unexpected input, in a production system.

For a hands-on SQL follow-up, use the users and production_events tables. Treat supported event types as valid only when their timestamp is present and their value is either nonnegative or NULL.

Output

  1. One row per user, including users with no events
  2. Columns: user_id, email, valid_event_count, anomaly_count, and latest_valid_at
  3. Exclude unknown users from the result, count invalid known-user events as anomalies, and sort by user_id ascending

Schema

users
ColumnTypeDescription
user_idPKINTUnique identifier for a known user
emailVARCHAR(255)User email address
external_keyVARCHAR(64)Optional identifier from an external system
production_events
ColumnTypeDescription
event_idPKINTUnique production event identifier
user_idINTUser associated with the event, when known
event_typeVARCHAR(64)Reported event type
occurred_atTIMESTAMPTime at which the event occurred
valueDECIMAL(10,2)Optional nonnegative event value
sourceVARCHAR(32)Originating ingestion source
Tablesusersproduction_events
Interviewer

Your question is Data Manipulation Gotchas. 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.