I know about pivot and unpivot. That is not what I want. Pivot and unpivot aggregate data, but that is not what I want.
Think of a table as a matrix (linear algebra). If I start with an m x n matrix, I want to convert that matrix (table) into an n x m matrix. I want a true TRANSPOSE.
How can I do this in SQL?
For example if I have:
1 2 3
1 2 4
6 7 8
3 2 1
3 9 1
then the result should be:
1 1 6 3 3
2 2 7 2 9
3 4 8 1 1
Notice that the number of rows becomes the number of columns, and vice versa. Also notice that I have not grouped or aggregated any of the data. Every single value present in the source is present in the result, and their x-y coordinates have been swapped.
See Question&Answers more detail:os