Q&A for system and network administrators
declare @start datetime = ( select top 1 dateadd(day, datediff(day, getdate(), CreationDate), getdate()) from Posts group by datediff(day, getdate(), CreationDate) having count(*) >= ##threshold?10## order by datediff(day, getdate(), CreationDate) ); declare @stop datetime = ( select top 1 dateadd(day, datediff(day, getdate(), CreationDate), getdate()) from Posts group by datediff(day, getdate(), CreationDate) having count(*) >= ##threshold## order by datediff(day, getdate(), CreationDate) desc ); select dateadd(week, datediff(week, @start, CreationDate), @start), count(*)/7.0 QpD from Posts where CreationDate between @start and @stop and PostTypeId = 1 group by datediff(week, @start, CreationDate) order by datediff(week, @start, CreationDate)