Posts over time

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

declare @start datetime = (
select top 1 dateadd(day, datediff(day, getdate(), CreationDate), getdate())
from Posts
group by datediff(day, getdate(), CreationDate)
having count(*) >= ##betathreshold?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(*) >= ##betathreshold##
order by datediff(day, getdate(), CreationDate) desc
);

select dateadd(week, datediff(week, @start, CreationDate), @start),
       pt.Name,
       count(*)/7.0 Post
from PostsWithDeleted
     join PostTypes pt on pt.id=PostTypeId
where CreationDate between @start and @stop
      and pt.id < 3
group by datediff(week, @start, CreationDate),
         pt.Name
order by datediff(week, @start, CreationDate)

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results