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----