Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
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 feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Impute Sparse Assessment Scores
00:00
5 left

Impute Sparse Assessment Scores

HardSQL · PostgreSQL

Problem

You are given sparse assessment score data from Mercor assessments, where many candidate-question scores are missing and some recorded scores fall outside the valid 0-100 range. Write a PostgreSQL query that returns one row per candidate and assessment with a cleaned average score. Treat negative scores and scores above 100 as invalid, normalize valid scores to the 0-1 range, and impute missing or invalid scores using the average cleaned score for that question within the same assessment. If a question has no valid scores at all, fall back to the assessment-level cleaned average. Return only candidate-assessment pairs that have at least one assignment.

Schema

assessment_assignments
ColumnTypeDescription
assignment_idPKINTUnique assignment row
candidate_idINTCandidate taking the assessment
assessment_idINTAssessment identifier
question_idINTQuestion identifier within the assessment
assigned_atDATEDate the question was assigned
assessment_scores
ColumnTypeDescription
score_idPKINTUnique score row
assignment_idINTAssignment being scored
raw_scoreDECIMAL(5,2)Raw score, may be NULL or outside the valid range
assessments
ColumnTypeDescription
assessment_idPKINTAssessment identifier
assessment_nameVARCHAR(100)Assessment name
Tablesassessment_assignmentsassessment_scoresassessments
Interviewer

Your question is Impute Sparse Assessment Scores. 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.