Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Missing Marks Rule

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is SQL Missing Marks Rule. Start with the requirements and the one table 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

PayPal's analyst training dataset contains one row per student and subject. Before calculating performance metrics, exclude students whose marks are missing in two or more subjects.

Write a PostgreSQL query that returns the students who should remain after this exclusion.

Requirements

  1. Count missing marks separately for each student, where a missing mark is represented by NULL.
  2. Exclude students with missing marks in two or more subjects.
  3. Return each retained student's ID and name, ordered by student_id.

Each student has at most one row per subject, so each NULL mark represents one missing subject mark.

Schema

student_marks
ColumnTypeDescription
student_idINTStudent identifier
student_nameVARCHAR(100)Student's full name
subject_nameVARCHAR(100)Subject being assessed
marksNUMERIC(5,2)Marks earned, or NULL when the mark is missing
Tablesstudent_marks
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results