This query shows me the date/time when the VPN user count reaches its max per day.
I don't have any issues when using this query in Management Studio, but when creating a report using SQL it says it is an invalid query.
I removed 'ranks' from the query and it works, but provides all data not just the top count. Maybe because NPM doesn't recognize the Status_Rank column
Any ideas?
WITH ranks AS
(
SELECT [Status]
, [DateTime]
, RANK() OVER (PARTITION BY DATEADD(DAY,0, DATEDIFF(DAY,0, [DateTime])) ORDER BY [Status] DESC) status_rank
FROM [SolarWindsOrion].dbo.CustomPollerStatistics_Detail
WHERE CustomPollerAssignmentID = '98C0CC90-B014-4721-A84A-027A2A064527'
)
SELECT *
FROM ranks WHERE status_rank = 1
Results
Status DateTime status_rank
2288 2020-06-16 12:02:37.837 1
2284 2020-06-17 14:35:21.147 1
2297 2020-06-18 09:35:21.927 1