Votes by month

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

SELECT 
datepart(YEAR,CreationDate)*100 + 100*(DATEpart(MONTH, CreationDate)/12.0) AS [Date], 
--    COUNT(*) AS Amount, 
--    SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END) AS UpVotes, 
--    SUM(CASE WHEN VoteTypeId = 3 THEN 1 ELSE 0 END) AS DownVotes,
    SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END) / CAST(count(*) as float) AS percent_up_vote
FROM Votes
WHERE votetypeid in (2,3)
GROUP BY DATEpart(MONTH, CreationDate),datepart(YEAR,CreationDate)
ORDER BY date

Enter Parameters

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