DECLARE @pivoted TABLE
(year int, Q1 money, Q2 money, Q3 money, Q4 money)

INSERT INTO @pivoted SELECT * FROM SalesByQuarter
PIVOT
( SUM (amount)
FOR quarter IN (Q1, Q2, Q3, Q4)
) AS P

SELECT * FROM @pivoted
UNPIVOT
(Amount FOR Quarter IN (Q1, Q2, Q3, Q4)
) AS U
a
b
c
d
