Kodewick
Start learning →
Mini challenge←→0 / 70

Honour roll

#065Mini challengeJOINGROUP BY7 min

The school's honour roll only lists students whose average is 80 or more. Group by student, work out each one's average score over all subjects (empty scores don't count), and keep those at 80 or above. Pick name and the average with ROUND(…, 1).

The tables
students
idnameclassagecity
1Amy1A12Leeds
2Ben1A13York
3Cara1B12NULL
4Dan1B14Leeds
5Eva1A12Hull
6Finn1C13NULL
7Gus1C12York
7 rows
scores
idstudent_idsubjectscore
11math92
21art78
32math65
42art88
53math74
64math55
74art90
85math81
95artNULL
107math99
10 rows
query.sql
SELECT students.name, ROUND(AVG(scores.score), 1)
FROM students
JOIN scores ON scores.student_id = students.id
-- your code here: GROUP BY students.name, then HAVING to keep AVG(scores.score) >= 80
;
Ctrl + Enter runs too
Result

Run shows what your query gives. When it looks right, Submit.