Q&A for professionals and students of engineering
WITH downvotes AS ( SELECT post.ownerUserID as victim, post.id as post, vote.creationDate as date, count(vote.id) as number FROM posts as post inner join votes as vote on vote.postID = post.id and datediff(day,post.creationdate,vote.creationdate) > ##threshold## WHERE vote.voteTypeID = 3 -- downvote GROUP BY post.ownerUserID, post.id, vote.creationDate ) select victim as [User Link], date, count(post) as 'distinct posts', sum(number) as 'total downvotes' from downvotes group by victim, date order by 'distinct posts' desc