Students table

```
student_id  student_name
1           John
2           Mary

```

Grades table

```
student_id   year   grade_level  school        Course    Mark
  1          2015    10          Smith High     Algebra   95
  1          2015    10          Smith High     English   96
  1          2016    11          Smith High     Geometry  85
  1          2016    11          Smith High     Science   88
  2          2015    10          Smith High     Algebra   98
  2          2015    10          Smith High     English   93
  2          2016    11          Smith High     Geometry  97
  2          2016    11          Smith High     Science   86

```

I'm trying to show results for each year and what class a student took with the grade.

So the final output i'm looking for is something like:

```
[student_id1] [year1] [grade1] [school1]
[course1] [mark1]
[course2] [mark2]
[course3] [mark3]...
[student_id1] [year2] [grade2] [school1]
[course1] [mark1]
[course2] [mark2]
[course3] [mark3]...
[student_id2] [year1] [grade1] [school1]
[course1] [mark1]
[course2] [mark2]
[course3] [mark3]...

```

This would all go in one column/row. So in this particular example, this would be my result:

```
1 2015 10 Smith High 
Algebra 95
English 96
1 2016 11 Smith High 
Geometry 85
Science 88
2 2015 10 Smith High 
Algebra 98
English 93
2 2016 11 Smith High 
Geometry 97
Science 86

```

So anytime a student id, year, grade, or school name changes, I would have a line for that and loop through the classes taken within that group. And all of this would be in one column/row.

This is what I have so far but I'm not sure how I can properly loop through course and grades for each group. I'd appreciate it if I can be pointed in the right direction.

```
select s.student_id + '' + year + '' + grade_level + '' + school 
from students
join grades on students.student_id = grades.student_id

```