I have query like this:
SELECT
Column,
SUM(Row1) AS Row1,
SUM(Row2) AS Row2,
SUM(Row3) AS Row3,
SUM(Row4) AS Row4,
SUM(Row5) AS Row5,
SUM(Row6) AS Row6,
SUM(Row7) AS Row7,
SUM(Row8) AS Row8,
SUM(Row9) AS Row9,
SUM(Row10) AS Row10,
SUM(Row11) AS Row11,
SUM(Row12) AS Row12,
SUM(Row13) AS Row13,
SUM(Row14) AS Row14,
SUM(Row15) AS Row15,
SUM(Row16) AS Row16,
SUM(Row17) AS Row17
FROM #temp
GROUP BY
Column
I get result like this:
Column Row1 Row2
----------- --------------------------------------- ---------------------------------------
1 45.00 0.00
2 19.00 0.00
And would like to get this:
Row 1 2
----------- --------------------------------------- ---------------------------------------
Row1 45.00 19.00
Row2 0.00 0.00
But the column number can vary, and the syntax has to be compatible with sql server 2005. How can I achive something like this?