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
ExperiencesCoaching
New
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
Get started
Impute Missing Scores by Assessment Median
00:00
5 left

Impute Missing Scores by Assessment Median

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

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the three tables are in the Question tab.

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.