With a lot of fluffing around that wouldn't be necessary if you redesigned your tables.
Student
- student_id
- name
- grade
- other student stuff
Group
- group_id
- other group stuff
Student_Group
- group_id
- student_id
If there is no "other group stuff" then it's still two tables, but it still needs fixing.
Student
- student_id
- name
- grade
- other student stuff
Student_Group
- group_id
- student_id
In both Student_Group tables, there is only one student ID in the student_id field. If there are several students in the same group, there are several rows in the table.
Average grade for group $group:
Select
avg(Student.grade)
from
Student,
Student_Group
where
Student.student_id=Student_Group.student_id
and
Student_Group.group_id=$group