Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Handling Missing Data
00:00
5 left

Handling Missing Data

MediumSQL · PostgreSQL

Problem

How would you handle missing data before analysis and modeling?

For this SQL exercise, treat a missing score as either a NULL score or an absent score record. Replace missing scores with the median observed score for the same assessment type, while preserving complete records.

Output

  1. One row per assignment, ordered by assignment_id.
  2. Return assignment_id, learner_name, assessment_type, original_score, cleaned_score, and was_missing.
  3. was_missing must indicate whether the original score was missing.

Schema

learners
ColumnTypeDescription
learner_idPKINTUnique learner identifier
learner_nameVARCHAR(100)Learner's display name
assessment_assignments
ColumnTypeDescription
assignment_idPKINTUnique assessment assignment identifier
learner_idINTLearner assigned to the assessment
assessment_typeVARCHAR(30)Assessment category
assessment_scores
ColumnTypeDescription
score_idPKINTUnique score record identifier
assignment_idINTRelated assessment assignment
scoreNUMERIC(5,2)Observed assessment score from 0 to 100
Tableslearnersassessment_assignmentsassessment_scores
Interviewer

Your question is Handling Missing Data. Start with the requirements and the three 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.