I have a table which looks like the table given below. This table holds the information about students and their answers to some multiple choice questions. Consider that number of questions might be different in each exam.
+--------+---------------+-------------+
| Person | QuestionIndex | ChoiceIndex |
+--------+---------------+-------------+
| John | 1 | 01 |
| John | 2 | 02 |
| John | 3 | 04 |
| Peter | 1 | 01 |
| Peter | 2 | 03 |
| Peter | 3 | 04 |
| Jack | 1 | 01 |
| Jack | 2 | 02 |
| Jack | 3 | 03 |
+--------+---------------+-------------+
Now, I would like to change rows to columns using pivot to a layout such as this:
+--------+----+----+----+
| Person | Q1 | Q2 | Q3 |
+--------+----+----+----+
| John | 01 | 02 | 04 |
| Peter | 01 | 03 | 04 |
| Jack | 01 | 02 | 03 |
+--------+----+----+----+
Which columns are question indexes. and each field hold the choice of the user for that question in a multiple choice exam.
I would like to do this using pivot. Can anybody help doing this?