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
Median Imputation and Missingness Indicators
00:00
5 left

Median Imputation and Missingness Indicators

MediumSQL · PostgreSQL

Problem

You are given a dataset with missing values. What steps would you take to handle this?

Using the supplied PostgreSQL tables, write a query that returns a cleaned but auditable application-level dataset. Use explicit treatments for missing categorical and numeric values, while retaining indicators for values that remain unknown.

Output

  1. One row per application, including applications without a matching candidate.
  2. Columns: application_id, candidate_id, candidate_name, location, years_experience, status, salary_expectation, applied_on, and applied_on_missing.
  3. Replace missing names, locations, and statuses with Unknown, replace missing salaries with the non-null median salary, retain unknown experience and dates as NULL, and sort by application_id ascending.

Output details

  • Define the salary median as the discrete 50th percentile over non-NULL salary values, without rounding.
  • Set applied_on_missing to True exactly when applied_on is NULL, otherwise False.

Schema

candidates
ColumnTypeDescription
candidate_idPKINTUnique candidate identifier
candidate_nameVARCHAR(100)Candidate's name
locationVARCHAR(100)Candidate's current location
years_experienceINTReported years of professional experience
applications
ColumnTypeDescription
application_idPKINTUnique application identifier
candidate_idINTCandidate associated with the application
statusVARCHAR(30)Current application status
salary_expectationDECIMAL(10,2)Candidate's expected annual salary
applied_onDATEDate the application was submitted
Tablesapplicationscandidates
Interviewer

Your question is Median Imputation and Missingness Indicators. 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.