Students with the Most Late Submissions
A submission is late when submitted_on is later than the assignment's due_date (unsubmitted work has NULL and does not count). Return student_id and late (the number of late submissions) for the five students with the most late submissions. Sort by late from high to low, then by student_id.
Hint 1
Join submissions to assignments on assignment_id.
Hint 2
Text dates in YYYY-MM-DD form compare correctly with >.
Reference solution
SELECT s.student_id, COUNT(*) AS late
FROM submissions AS s
JOIN assignments AS a ON a.assignment_id = s.assignment_id
WHERE s.submitted_on > a.due_date
GROUP BY s.student_id
ORDER BY late DESC, s.student_id
LIMIT 5;
The condition that defines "late" compares columns from two tables, so it needs the join first. NULL > anything is unknown, so unsubmitted work (submitted_on IS NULL) drops out of the WHERE automatically: sometimes that is what you want, but only because you decided it on purpose. Then it is an ordinary group, count and top five with a tie-breaker.