Views per vote

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

WITH ViewsPerVoteByMonth  AS (
    SELECT DATEADD (month, DATEDIFF (month, 0, v.CreationDate), 0)  AS [Month],
    COUNT (v.Id) AS Votes

    FROM Votes v 
    JOIN Posts p ON (p.Id = v.PostId) AND p.PostTypeId = 1
    WHERE v.VoteTypeId=1 or v.VoteTypeId=2 and DATEDIFF(day, p.CreationDate, v.CreationDate) < 31

    GROUP BY DATEADD (month, DATEDIFF (month, 0, v.CreationDate), 0)
)

SELECT
    v.[Month], 
    v.Votes AS 'votes'

FROM ViewsPerVoteByMonth v

Enter Parameters

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