I have a table like this
And I want result like this
I tried pivoting but could not get this result. Because there can be more than four values in first table.
NOTE: this is question is quite different from the mentioned above by some one. The answer in the similar question shows another result set, while I have attached images to avoid such stupid confusion.