I have a table with the following entries:
+------------+-----------+----------+
| screenId | userInput | numInput |
+------------+-----------+----------+
| 13_1_2_1 | 2 | 9 |
| 13_1_2_2 | 2 | 9 |
| 13_1_2_2 | 3 | 2 |
| 13_1_2_2 | 9 | 2 |
| 13_1_2_2_2 | 3 | 3 |
| 13_1_2_2_2 | 5 | 2 |
| 13_2_2_2 | 4 | 4 |
| 13_2_2_2 | 5 | 4 |
| 13_2_2_2 | 7 | 2 |
+------------+-----------+----------+
I need to frame a query which gives the output as:
+------------+---+---+---+---+---+---+---+---+---+---+
| screenId | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
+------------+---+---+---+---+---+---+---+---+---+---+
| 13_1_2_1 | 0 | 0 | 9 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 13_1_2_2 | 0 | 0 | 9 | 2 | 0 | 0 | 0 | 0 | 0 | 2 |
| 13_1_2_2_2 | 0 | 0 | 0 | 3 | 0 | 2 | 0 | 0 | 0 | 0 |
| 13_2_2_2 | 0 | 0 | 0 | 0 | 4 | 4 | 0 | 2 | 0 | 0 |
+------------+---+---+---+---+---+---+---+---+---+---+
Here 0-9 column values are the userInput values and the values against them are the numInput values. for example first row means the numInput for the value userInput '2' and screenID '13_1_2_1' is '9'.
I am unable to frame a proper query for this problem. Please help.