Question stats for a week

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 = '##start?2017-10-08##';
declare @end datetime = @start+7;

select @start 'Week of',
       count(*) questions,
       sum(iif(Score > 0, 1, 0)) upvoted,
       sum(iif(Score < 0, 1, 0)) downvoted,
       sum(iif(Score = 0, 1, 0)) zero,
       sum(iif(AnswerCount > 0, 1, 0)) answered,
       sum(iif(ClosedDate is not null, 1, 0)) closed,
       sum(iif(DeletionDate is not null, 1, 0)) deleted,
       sum(iif(DeletionDate is not null or ClosedDate is not null or Score < 0, 1, 0)) bad,
       sum(iif((DeletionDate is not null or ClosedDate is not null or Score < 0) and AnswerCount > 0, 1, 0)) bad_answered
from PostsWithDeleted
where PostTypeId = 1
      and CreationDate between @start and @end

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results