Command Shell Examples
Useful SQL Queries
Number of alerts raised per day for last 28 days - Jonathan Almquist on Operations Manager - Site Home - TechNet Blogs

Number of alerts raised per day for last 28 days

Number of alerts raised per day for last 28 days

  • Comments 2
  • Likes

/*Number of alerts raised per day for last 28 days.*/
USE OperationsManagerDW
SELECT CONVERT(VARCHAR(10), DBCreatedDateTime, 101) AS Date, COUNT(*) AS Alerts
FROM  Alert.vAlert
WHERE (DBCreatedDateTime BETWEEN DATEADD(day, -27, GETDATE()) AND GETDATE())
GROUP BY CONVERT(VARCHAR(10), DBCreatedDateTime, 101)
ORDER BY Date DESC

Back to SQL queries main menu

I do not moderate this blog anymore. If you have a question regarding this post, send me a message.

Comments
  • Hi, Jonathan

    Do you know how to specify the data range instead of the last 28 days? for example from Nov 1 to Nov. 28

  • Hi Lisa,

    No problem.  Just replace the WHERE clause in the above statement from:

    WHERE (DBCreatedDateTime BETWEEN DATEADD(day, -27, GETDATE()) AND GETDATE())

    To:

    WHERE (CONVERT(VARCHAR(10), DBCreatedDateTime, 101) BETWEEN 'DD/MM/YYYY' and 'DD/MM/YYYY')

    Just plug in your date range.

    -Jonathan