SELECT
Nodes.Caption AS [Device],
Nodes.DetailsURL AS [_LinkFor_Device],
'/Orion/images/StatusIcons/Small-' + StatusIcon AS [_IconFor_Device],
Nodes.IP_Address AS [IP],
Nodes.DetailsURL AS [_LinkFor_IP],
DATETRUNC('MINUTE', Alerts.SuppressFrom) AS [Mute from],
DATETRUNC('MINUTE', Alerts.SuppressUntil) AS [Mute Until],
NULL AS [Custom m_Mute],
Nodes.CustomProperties.Comments
JOIN Orion.nodes ON Nodes.uri = AlertS.EntityURI
UNION
(SELECT
Nodes.caption AS [Device],
Nodes.DetailsURL AS [_LinkFor_Device],
'/Orion/images/StatusIcons/Small-' + StatusIcon AS [_IconFor_Device],
Nodes.IP_Address AS [IP],
Nodes.DetailsURL AS [_LinkFor_IP],
NULL AS [Mute from],
NULL AS [Mute Until],
Nodes.CustomProperties.m_Mute AS [Custom m_Mute],
Nodes.CustomProperties.Comments
Nodes.Status != '2'
AND Nodes.CustomProperties.m_Mute = 'TRUE')