Business Analytics · Problem 92 of 118

Gradebook Percentages

HardBusiness AnalyticsSchool data

A student's overall percentage is 100 * (sum of points) / (sum of max_points) over their graded submissions (points is not NULL). Return student_id, graded (number of graded submissions) and percent (rounded to 1 decimal) for students with at least 25 graded submissions. Show the five highest percentages, sorted by percent from high to low, then student_id.

Hint 1

Join submissions to assignments to know the maximum points of each assignment.

Hint 2

A weighted overall percentage divides the totals, not an average of percentages.

Reference solution

SELECT s.student_id,
       COUNT(*) AS graded,
       ROUND(100.0 * SUM(s.points) / SUM(a.max_points), 1) AS percent
FROM submissions AS s
JOIN assignments AS a ON a.assignment_id = s.assignment_id
WHERE s.points IS NOT NULL
GROUP BY s.student_id
HAVING COUNT(*) >= 25
ORDER BY percent DESC, s.student_id
LIMIT 5;

Work that has not been graded must be excluded from both the numerator and the denominator. If a missing grade stays in the denominator (its max_points) but contributes nothing to the numerator, the student is punished for something that is not their score. Dividing totals (a weighted percentage) also differs from averaging each assignment's percentage, which would treat a 10-point quiz like a 100-point exam.