Whose Grade Never Got Entered?
Fairhaven University's registrar has spotted a hole in the gradebook: a transcript is being held up because one enrolment has no mark against it. Before chasing the instructor, she needs to know exactly which student and which course are involved.
An enrolment row is created when a student signs up for a course, months before any mark exists. Until the instructor submits one, the grade slot holds NULL — SQL's marker for a value that was never recorded. It is not a zero and not an empty string, and it does not behave like an ordinary value when you compare it, which is the point of this exercise.
enrollments — one row per student-course enrolment. grade is the mark out of 4.0, or NULL if none has been entered. There is no id column: a row is identified by the pair student_id and course_id.
| student_id | course_id | grade | semester |
|---|---|---|---|
| 1 | 1 | 3.7 | Fall2023 |
| 1 | 2 | 3.9 | Spring2024 |
| 2 | 1 | 3.2 | Fall2023 |
| 2 | 3 | 3.5 | Fall2023 |
| 3 | 2 | 4.0 | Spring2024 |
| 3 | 4 | 3.8 | Spring2024 |
| 4 | 3 | 2.9 | Fall2023 |
| 5 | 1 | 3.6 | Fall2023 |
| 5 | 2 | NULL | Spring2024 |
The table already exists in the database — there is nothing to create or load.
Task: Write a query returning two columns, student_id and course_id, for every enrolment with no grade recorded. Exactly one enrolment qualifies here, so one row comes back.
Example output — shape only, on an invented pairing of ids.
| student_id | course_id |
|---|---|
| 3 | 8 |
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in