SQL / MySQL Intermediate
Code only
Average quiz score per course with JOIN and GROUP BY
Combine two tables and summarise the results.
JOIN matches each attempt to its course; GROUP BY then gives one row per course with its average.
SELECT c.title AS course,
COUNT(a.id) AS attempts,
ROUND(AVG(a.score), 1) AS average_score
FROM courses c
JOIN quiz_attempts a ON a.course_id = c.id
WHERE a.status = 'submitted'
GROUP BY c.id, c.title
HAVING COUNT(a.id) >= 5
ORDER BY average_score DESC;
Code only · preview unavailable
SQL is shown for reading. Try it in your own MySQL database (for example in phpMyAdmin); it is never run against this site.