Hello,
I created a temp "#ToPivot" table that holds the following values:
ServerName Date CountHits
ServerA 4/25/2011 4
ServerA 4/26/2011 2
How do I generate a table based on the above one that would look like this:
ServerName 4/25/2011 4/26/2011
ServerA 4 2
This is the code I tried:
SELECT [ServerName], 04/25/11, 04/26/11
FROM
(SELECT ServerName,
[Date],
Hits
FROM #ToPivot
) AS Src
PIVOT
(
SUM(Src.Hits)
FOR Src.[Date] IN ([4/25/2011], [4/26/2011])
) AS pvt
and it gives me the following result set:
ServerName (No column name) (No column name)
HNWAS3535 0 0
NPWAS5065 0 0
I would really appreciate a hand on this since I need to generate this data as soon as possible.
Thank you very much everyone
I created a temp "#ToPivot" table that holds the following values:
ServerName Date CountHits
ServerA 4/25/2011 4
ServerA 4/26/2011 2
How do I generate a table based on the above one that would look like this:
ServerName 4/25/2011 4/26/2011
ServerA 4 2
This is the code I tried:
SELECT [ServerName], 04/25/11, 04/26/11
FROM
(SELECT ServerName,
[Date],
Hits
FROM #ToPivot
) AS Src
PIVOT
(
SUM(Src.Hits)
FOR Src.[Date] IN ([4/25/2011], [4/26/2011])
) AS pvt
and it gives me the following result set:
ServerName (No column name) (No column name)
HNWAS3535 0 0
NPWAS5065 0 0
I would really appreciate a hand on this since I need to generate this data as soon as possible.
Thank you very much everyone
