Comments per Week

0

Please login or register to vote for this query.

(click on this box to dismiss)

The Workplace

Q&A for members of the workforce navigating the professional setting

declare @epoch datetime = '2014-08-26';

SELECT DATEADD(week, datediff(week, @epoch, p.CreationDate), @epoch) as Week,
    count(distinct c.Id) as Comments,
    count(distinct p.Id) as Posts,
    100.0*count(distinct c.Id)/count(distinct p.Id) C_per_P_100,
    sum(c.Score) Comment_votes
from Comments c
     right outer join Posts p on p.Id = PostId
--where p.CreationDate > @epoch - 4*datediff(day, @epoch, getdate())
Group by DATEADD(week, datediff(week, @epoch, p.CreationDate), @epoch) 
Order by DATEADD(week, datediff(week, @epoch, p.CreationDate), @epoch)

Enter Parameters

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