Break down the number of upvotes received each day by the age of the post.
Q&A for professional and enthusiast programmers
SELECT Convert(datetime, v.CreationDate, 102) AS [Day], Count(CASE WHEN DateDiff(second, p.CreationDate, v.CreationDate) > 30*86400 THEN 1 ELSE NULL END) AS [> 30 days], Count(CASE WHEN DateDiff(second, p.CreationDate, v.CreationDate) BETWEEN 7*86400+1 AND 30*86400 THEN 1 ELSE NULL END) AS [8–30 days], Count(CASE WHEN DateDiff(second, p.CreationDate, v.CreationDate) BETWEEN 86400+1 AND 7*86400 THEN 1 ELSE NULL END) AS [2–7 days], Count(CASE WHEN DateDiff(second, p.CreationDate, v.CreationDate) <= 86400 THEN 1 ELSE NULL END) AS [<=2 days], Count(*) AS [Total Votes] FROM Votes v, Posts p WHERE v.PostId = p.Id AND p.OwnerUserId = ##User## GROUP BY Convert(datetime, v.CreationDate, 112) ORDER BY Convert(datetime, v.CreationDate, 112) ASC