I have this query that was built in Management Studio but does not work when I am using it to create a report.
WITH AUOptions AS (SELECT [NodeID],[ComponentMessage] FROM [dbo].[APM_AlertsAndReportsData] WHERE [UserNotes] = 'AUOptions'),
ScheduledInstallTime AS (SELECT [NodeID],[ComponentMessage] FROM [dbo].[APM_AlertsAndReportsData] WHERE [UserNotes] = 'ScheduledInstallTime'),
ScheduledInstallDay AS (SELECT [NodeID],[ComponentMessage] FROM [dbo].[APM_AlertsAndReportsData] WHERE [UserNotes] = 'ScheduledInstallDay'),
TargetGroup AS (SELECT [NodeID],[ComponentMessage] FROM [dbo].[APM_AlertsAndReportsData] WHERE [UserNotes] = 'TargetGroup'),
WUServer AS (SELECT [NodeID],[ComponentMessage] FROM [dbo].[APM_AlertsAndReportsData] WHERE [UserNotes] = 'WUServer'),
KBCheck AS (SELECT [NodeID],[ComponentMessage] FROM [dbo].[APM_AlertsAndReportsData] WHERE [UserNotes] = 'KB Check'),
PendingPatches AS (SELECT [NodeID],[ComponentMessage] FROM [dbo].[APM_AlertsAndReportsData] WHERE [UserNotes] = 'Pending Patches'),
PendingReboot AS (SELECT [NodeID],[ComponentMessage] FROM [dbo].[APM_AlertsAndReportsData] WHERE [UserNotes] = 'Pending Reboot'),
RebootRequired AS (SELECT [NodeID],[ComponentMessage] FROM [dbo].[APM_AlertsAndReportsData] WHERE [UserNotes] = 'RebootRequired')
SELECT DISTINCT APM_AARD.[NodeName]
,AUOptions.[ComponentMessage] AS [AUOptions]
,ScheduledInstallTime.[ComponentMessage] AS [ScheduledInstallTime]
,ScheduledInstallDay.[ComponentMessage] AS [ScheduledInstallDay]
,TargetGroup.[ComponentMessage] AS [TargetGroup]
,WUServer.[ComponentMessage] AS [WUServer]
,KBCheck.[ComponentMessage] AS [KB Check]
,PendingPatches.[ComponentMessage] AS [Pending Patches]
,PendingReboot.[ComponentMessage] AS [Pending Reboot]
,RebootRequired.[ComponentMessage] AS [RebootRequired]
FROM [dbo].[APM_AlertsAndReportsData] APM_AARD
LEFT JOIN AUOptions ON APM_AARD.[NodeID] = AUOptions.[NodeID]
LEFT JOIN ScheduledInstallTime ON APM_AARD.[NodeID] = ScheduledInstallTime.[NodeID]
LEFT JOIN ScheduledInstallDay ON APM_AARD.[NodeID] = ScheduledInstallDay.[NodeID]
LEFT JOIN TargetGroup ON APM_AARD.[NodeID] = TargetGroup.[NodeID]
LEFT JOIN WUServer ON APM_AARD.[NodeID] = WUServer.[NodeID]
LEFT JOIN KBCheck ON APM_AARD.[NodeID] = KBCheck.[NodeID]
LEFT JOIN PendingPatches ON APM_AARD.[NodeID] = PendingPatches.[NodeID]
LEFT JOIN PendingReboot ON APM_AARD.[NodeID] = PendingReboot.[NodeID]
LEFT JOIN RebootRequired ON APM_AARD.[NodeID] = RebootRequired.[NodeID]
ORDER BY APM_AARD.[NodeName]