Have the ability to pivot a table in a custom report to display it as columns instead of rows. So for example I can currently generate a table like this:
SummaryMonth | NodeGroup | Average Availability | |
---|---|---|---|
January | NodeGroup1 NodeGroup2 | 99% 100% | |
February |
| 100% 100% | |
March |
| 95% 98% |
But would like the option to pivot the table and display it like this:
NodeGroup | January | February |
---|---|---|
NodeGroup1 | 99% | 100% |
NodeGroup2 | 100% | 100% |
The above is just a sample of what I am after. I am not sure the correct way to edit the SQL query to display the table the way I need it to look. I think I need to use a pivot command, but I do not know the syntax. When I create a report in report writer, this is the SQL that is generated:
Select SummaryMonth, Cast(AlertGroup01 As nvarchar(250)) as AlertGroup01, AVERAGE_of_Availability From ( SELECT TOP 10000 CONVERT(DateTime,
LTRIM(MONTH(DateTime)) + '/01/' + LTRIM(YEAR(DateTime)),
101) AS SummaryMonth,
Nodes.AlertGroup01 AS AlertGroup01,
AVG(ResponseTime.Availability) AS AVERAGE_of_Availability
FROM
Nodes INNER JOIN ResponseTime ON (Nodes.NodeID = ResponseTime.NodeID)
WHERE
( DateTime BETWEEN 41638 AND 41750 )
AND
(
(Nodes.AlertGroup01 = 'DAC-AI - Devices')
(Nodes.AlertGroup01 = 'FNBA - Devices')
)
GROUP BY CONVERT(DateTime, LTRIM(MONTH(DateTime)) + '/01/' + LTRIM(YEAR(DateTime)), 101),
Nodes.AlertGroup01
) As r ORDER BY SummaryMonth ASC
I should say "AlertGroup01" is a custom property I created. Any help on this would be greatly appreciated.