Questions grouped per hour of the day, posted less than X Days ago; also graphed
Q&A for historians and history buffs
-- Questions by Hour of Day -- Distribution of questions per hour of the day for a particular tag. SELECT CAST(STR(datepart(hour,p.creationdate)) AS int) as Hour, COUNT(datepart(hour,p.creationdate)) AS '# of questions' FROM Posts AS p WHERE p.PostTypeId = 1 -- Question -- and p.creationdate less than X weeks AND DATEDIFF(DAY, p.CreationDate, GETDATE()) < ##Days:int?7## GROUP BY datepart(hour, p.creationdate)