Using Pivot with a matrix-like table | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Using Pivot with a matrix-like table

Hello I have a table which is declared as Matrix(#Row as int, #Column as int, Value as numeric); this table stores data of a real matrix which has 20 rows and 5 columns. I would like to make a SELECT statement that uses the PIVOT operator in order to make a resultset of the matrix. Something like: Row Col1 Col2 Col3 Col4 Col5
1 23 45 46 78 89
2 12 56 34 79 23
… The data is stored as (select * from Matrix):
1, 1, 23
1, 2, 45
1, 3, 46
… Thanks a lot.

SQL Server 2005 Books Online
Using PIVOT and UNPIVOT http://msdn2.microsoft.com/en-us/library/ms177410.aspx
http://www.sqlmag.com/Article/ArticleID/42901/sql_server_42901.html MohammedU.
Moderator
SQL-Server-Performance.com All postings are provided “AS IS” with no warranties for accuracy.

]]>