So lets say that I have a table like this..
<tbody>
</tbody>
I want to transpose it so that it will be sorted according to the Type, I want it to look like so
<tbody>
</tbody>
How can I manage to do this? Oh, and I'll also point some stuff in case you guys missed it:
1. The Types have no particular order, if you notice Andy's, the order is F M V V, but Bobby's is M F V.
2. Multiple instances of Type may occur, just like in Andy's case, notice the double V. But even so, I want it so that the only V that counts is the first one, thats why in the transposed table, the V is Carrot, because the Carrot occurred first (the Spinach is ignored).
I dont know if I ask too much, but even just the gist of the solution would be very helpful for me. The main point of my question is to ask how can I transpose such unsorted items, whilst paying attention to the 1st point. The 2nd point is important too, but I can wait or ask later if you guys dont feel like answering.
Thanks for reading, please share me your knowledge.
TID | Person | Type | Name |
1 | Andy | F | Orange |
2 | Andy | M | Beef |
3 | Andy | V | Carrot |
4 | Andy | V | Spinach |
5 | Bobby | M | Ham |
6 | Bobby | F | Apple |
7 | Bobby | V | Carrot |
<tbody>
</tbody>
I want to transpose it so that it will be sorted according to the Type, I want it to look like so
Person | F | M | V |
Andy | Orange | Beef | Carrot |
Bobby | Apple | Ham | Carrot |
<tbody>
</tbody>
How can I manage to do this? Oh, and I'll also point some stuff in case you guys missed it:
1. The Types have no particular order, if you notice Andy's, the order is F M V V, but Bobby's is M F V.
2. Multiple instances of Type may occur, just like in Andy's case, notice the double V. But even so, I want it so that the only V that counts is the first one, thats why in the transposed table, the V is Carrot, because the Carrot occurred first (the Spinach is ignored).
I dont know if I ask too much, but even just the gist of the solution would be very helpful for me. The main point of my question is to ask how can I transpose such unsorted items, whilst paying attention to the 1st point. The 2nd point is important too, but I can wait or ask later if you guys dont feel like answering.
Thanks for reading, please share me your knowledge.