Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Missing Values Count

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is SQL Missing Values Count. Start with the requirements on the right.

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.

Problem

For a BCG X analytics workflow, records may contain incomplete values before they are processed. Given a collection of row records and a target column name, return how many rows have a missing value in that column.

Treat a value as missing when the column is absent from a row or its value is None. Do not treat valid values such as 0, False, or an empty string as missing.

Formal Specification

Implement count_missing_values(rows, column):

  • rows is a list of dictionaries, where each dictionary represents one record.
  • column is a string naming the column to inspect.
  • Return an integer equal to the number of rows where column is absent or mapped to None.
  • The input list and its dictionaries must not be modified.

Constraints

  • 0 <= len(rows) <= 10^5
  • Each row contains string keys and arbitrary values
  • column is a non-empty string
  • The function must inspect each row at most once

Function Signature

def count_missing_values(rows, column):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output