I am trying to pull the top 5 firing item from my database.
For example 2000 UserLogon Events on the 2022-08-13.
Currently when running the below query it will return the top events, but also the next 40 events as well.
Is there a way I can embed a TOP
or LIMIT
into the query per day instead of limiting the returned results?
Currently, my query looks like the following:
SELECT COUNT (M.EventID) AS TopEvent,
Name AS Event,
CAST (MsgDate AS DATE) AS time
FROM Events.dbo.Msg M
JOIN Alarms.dbo.Event E ON E.EventID = M.EventID
GROUP BY CAST (MsgDate AS DATE), Name,
A.EventID
ORDER BY CAST (MsgDate AS DATE), COUNT (MA.EventID) DESC