Friday, July 8, 2011

Usefull SQL queries part 2

I've gotten a lot of request on more queries. There is another one I use often. The one to determine when during the day you have the most activity.




SELECT datepart(HH, [dtInsertionTimeStamp]) as date,
count(Convert(char(10), [dtInsertionTimeStamp], 108)) as ant FROM [BizTalkDTADb].[dbo].[dta_MessageInOutEvents] WITH (NOLOCK) WHERE [dtInsertionTimeStamp] BETWEEN convert(datetime, '01-01-2011 00:00:00', 120) AND convert(datetime, '07-08-2011 23:59:59', 120) GROUP BY datepart(hh, [dtInsertionTimeStamp])ORDER BY [date]


all you need to do is change the date after the WHERE clause.

Good luck

No comments:

Post a Comment