Pending close votes by month

0

Please login or register to vote for this query.

(click on this box to dismiss)

Lists the number of questions with pending close votes by year and month that the first one was cast, along with number of questions with close votes and the avg close votes per question.

Mythology

Q&A for enthusiasts and scholars of mythology and folklore

with ClosingPosts as (
    SELECT
        Posts.Id as PostId,
        MIN(Votes.CreationDate) as FirstVoteTime,
        Count(Votes.Id) as Votes
    FROM Posts
    LEFT JOIN Votes on Posts.Id=Votes.PostId and VoteTypeId=6
    WHERE PostTypeId=1 and ClosedDate is null and Votes.Id is not null
    GROUP BY Posts.Id
)

select
    DATEPART(yyyy, FirstVoteTime) as Year,
    DATEPART(mm, FirstVoteTime) as Month,
    COUNT(*) as Questions,
    CONVERT(NUMERIC(3,2), CAST(SUM(Votes) as float) / COUNT(*)) as AvgCloseVotes
from ClosingPosts
GROUP BY DATEPART(yyyy, FirstVoteTime),DATEPART(mm, FirstVoteTime)
order by Year, Month

Enter Parameters

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