This changes the matrix of the table by making a column as rows and vice versa
SELECT Column1,
Column2 AS @name,
Column3 AS @name2
FROM
(SELECT query that produces the data)
AS @name
UNPIVOT/PIVOT
(
@name2
FOR
[<column that contains the values that will become column headers>]
IN ( Column1, COLUMN2,
) AS XYZ
<optional ORDER BY clause>;
SELECT Column1,
Column2 AS @name,
Column3 AS @name2
FROM
(SELECT query that produces the data)
AS @name
UNPIVOT/PIVOT
(
@name2
FOR
[<column that contains the values that will become column headers>]
IN ( Column1, COLUMN2,
) AS XYZ
<optional ORDER BY clause>;
No comments:
Post a Comment