I have a database like this:
duplicates of the combination of the variables id and sub_id are currently seperate rows in the datase and they can be distinqued by fol_id. I would like these to be in seperate columns. In this example the combinations: 'id=3 and sub-id=2' and 'id=5 and sub_id=1'
so the datase would be changed into:
Could anyone give me tips how to do this?
id | sub_id | fol_id | A | B |
1 | 1 | 1 | 15 | 6 |
2 | 1 | 1 | 20 | 6 |
2 | 2 | 1 | 25 | 7 |
3 | 1 | 1 | 25 | 6 |
3 | 2 | 1 | 15 | 7 |
3 | 2 | 2 | 20 | 7 |
3 | 2 | 3 | 25 | 7 |
4 | 1 | 1 | 15 | 6 |
5 | 1 | 1 | 15 | 5 |
5 | 1 | 2 | 15 | 6 |
so the datase would be changed into:
id | sub_id | fol_id1 | A1 | B1 | fol_id2 | A2 | B2 | fol_id3 | A3 | B3 |
1 | 1 | 1 | 15 | 6 | ||||||
2 | 1 | 1 | 20 | 6 | ||||||
2 | 2 | 1 | 25 | 7 | ||||||
3 | 1 | 1 | 25 | 6 | ||||||
3 | 2 | 1 | 15 | 7 | 2 | 20 | 7 | 3 | 25 | 7 |
4 | 1 | 1 | 15 | 6 | ||||||
5 | 1 | 1 | 15 | 5 | 2 | 15 | 6 |
Comment