Skip to the content

Who owes grades?

Problem

The school secretary wants to know which teachers need a reminder that there are grades to enter. For each teacher with students enrolled, show the teacher's name, how many grades they've already entered, and how many are still pending, in that order.

Some teachers teach more than one course: each shows up once, with all their courses added together. Grades go from 0 to 10, so a zero is a grade that's been entered, not one that's pending.

What it has to return

These rows, in any order

teacherenteredpending
Irene20
Paul30
Rose81

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, COUNT(*)
FROM grades g
JOIN courses c
  ON g.course_id = c.id
GROUP BY c.teacher
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) challenges

See all challenges →