SMS SQL for Count of Status Messages
The following SQL query returns a count of status messages by year, month, day, hour. The dateadd function subtracts 3 days from todays date, giving us counts for the last 3 days. ----Begin SQL---- --Count of Status Messages Broken Down by Year, Month, Day, Hour Select Datepart(yy,time), Datepart(mm,time), Datepart(dd,time), Datepart(hh,time), Count(*) FROM StatusMessages Where Time > dateadd(dd, -3, getdate()) Group By Datepart(yy,time), Datepart(mm,time), Datepart(dd,time), Datepart(hh,time) ----End SQL---- About the Author Emmanuel Tsouris is a Systems Management veteran and Developer Advocate specializing in PowerShell and Cloud Automation. He maintains DotVBS to preserve legacy knowledge for the "archaeologist admin." Ready to move from VBScript to the Cloud? Check out his book, Pro PowerShell for Amazon Web Services . ...