Posted in General DB but got no responses so I will try here.
The query is basically pulling all of our custom poller stats for customer reporting requirements.
Here is the query:
SELECT DATEADD (hour, DATEDIFF (hour, 0, CustomPollerStatistics.DateTime), 0)
AS DateTime,
MIN (CustomPollerStatistics.MinRate) AS MinRate,
AVG (CustomPollerStatistics.AvgRate) AS AvgRate,
MAX (CustomPollerStatistics.MaxRate) AS MaxRate,
SUM (CustomPollerStatistics.Total) AS Total,
MIN (CustomPollerStatistics.RawStatus) as RawStatus,
MIN (CustomPollerStatistics.Status) as Status,
CustomPollerAssignment.NodeID,
CustomPollerAssignment.InterfaceID,
CustomPollers.UniqueName,
CustomPollers.Description
FROM (SolarWindsOrion.dbo.CustomPollerAssignment CustomPollerAssignment
INNER JOIN SolarWindsOrion.dbo.CustomPollers CustomPollers
ON (CustomPollerAssignment.CustomPollerID =
CustomPollers.CustomPollerID))
INNER JOIN SolarWindsOrion.dbo.CustomPollerStatistics CustomPollerStatistics
ON (CustomPollerStatistics.CustomPollerAssignmentID =
CustomPollerAssignment.CustomPollerAssignmentID)
WHERE (DATEADD (hour,
DATEDIFF (hour, 0, CustomPollerStatistics.DateTime),
0) >= GETDATE () - 30)
AND CustomPollers.UniqueName IN
('gprsAttached',
'gprsNetworkTechnology',
'gprsRegistered',
'gprsSignalStrength')
GROUP BY CustomPollerAssignment.NodeID,
CustomPollerAssignment.InterfaceID,
CustomPollers.UniqueName,
CustomPollers.Description,
DATEADD (hour,
DATEDIFF (hour, 0, CustomPollerStatistics.DateTime),
0)