我有这样的查询:
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
我得到这样的结果:
Column Row1 Row2
----------- --------------------------------------- ---------------------------------------
1 45.00 0.00
2 19.00 0.00
并想得到这个:
Row 1 2
----------- --------------------------------------- ---------------------------------------
Row1 45.00 19.00
Row2 0.00 0.00
但是列号可能会有所不同,并且语法必须与 sql server 2005 兼容。我怎样才能达到这样的效果?