Skip to the content

The easy graders

Problem

Word in the hallway is that with certain teachers, nobody fails. The vice principal wants to know which ones: the teachers who haven't given a single failing grade in any of their courses. Grades go from 0 to 10. A 6 passes.

Show a single column, the teacher, with each one listed once even if they teach two courses. One failing grade in one of their courses is enough to keep a teacher off the list, however well the other course is going. A grade that hasn't been entered isn't a failing grade. And in a course with nobody enrolled, nobody has failed: a teacher whose only course is like that is on the list too.

What it has to return

These rows, in any order

teacher
Paul
Irene

This is what comes out with the data in the practice database this challenge uses. The column names don’t count, so name yours however you like: what counts is how many there are and the order they come in. Besides this one, the challenge has hidden tests with other data that are revealed when you submit your solution.

You start with this

SQL

SELECT c.teacher, g.grade
FROM grades g
JOIN courses c
  ON g.course_id = c.id
WHERE g.grade < 6;
Solve this challenge

It opens in your browser, with the editor and the tests. This challenge is part of the full plan; the O(1) and O(log n) ones are free.

More O(n log n) challenges

See all challenges →