All what you have to do is to count the number of occurrences for that student. For example:
SELECT COALESCE(SUM(CASE WHEN StudentID=@stuid THEN 1 ELSE 0 END), 0) AS NoOfOccurr
FROM TableWhereStudentIsAssignedToGroup
Note: you did not provide a structure of database or sample data, so above query is just an example.
There's few other ways to achieve that, but knowing nothing about a database, i can't help.