I have a database that is something like the following:
+------------+-----------+------------+
| student_id | subject | test score |
+------------+-----------+------------+
| 3 | math | 78 |
| 3 | physics | 66 |
| 3 | english | 98 |
| 2 | math | 76 |
| 2 | physics | 57 |
| 2 | geology | 87 |
| 2 | english | 99 |
| 1 | math | 86 |
| 1 | physics | 85 |
| 1 | astronomy | 89 |
| 1 | history | 77 |
+------------+-----------+------------+
I would like to group the subject_ids. The labels in the second column would become columns, and the new rows would be the scores. So it should look something like this:
+------------+------+---------+---------+---------+-----------+
| student_id | math | physics | english | geology | astronomy |
| 1 | 86 | 85 | | | 89 |
| 2 | 76 | 57 | 99 | 87 | |
| 3 | 78 | 66 | 98 | | |
+------------+------+---------+---------+---------+-----------+