I got 2 tables like that:
STUDENT
ID | Name | Class
1 | Jonh | 12
2 | Smit | 11
3 | David | 10
4 | Simon | 11
5 | Kate | 12
6 | Marry | 11
SCORE
Studentid | Score
4 | 10
1 | 5
2 | 7
3 | 9
5 | 8
I need to calculate Average for each class like this
Class| Average
10 | 9
11 | 8.5
12 | 6.5
Please help me to do that. I tried this :
SELECT stud.class, AVG(scor.mark) AS avg_mark
FROM STUDENT stud
INNER JOIN SCORE scor ON stud.id = scor.studentid
GROUP BY stud.class
Any help would be greatly appreciated