comments per post


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 @endDate date;
select @endDate = max(creationdate) from comments;
declare @daysPerBin int= ##daysPerBin?7##;

select d,cast(sum(numComments) as float) / count(postId) as meanComments
(select dateadd(day,
@daysPerBin * (datediff(day, @endDate, max(p.creationdate))/@daysPerBin),
  @endDate) as d,count( as numComments, as postId
from posts p
join comments c
on = c.postid
group by as x
group by d
order by d asc

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results