Number of upvotes depending on age of the post

1

Please login or register to vote for this query.

(click on this box to dismiss)

Physics

Q&A for active researchers, academics and students of physics

;with votes_cte as (
SELECT DATEDIFF(day, p.CreationDate, v.CreationDate) AS Days, v.Id as vid
FROM Votes v JOIN Posts p ON v.PostId=p.Id
WHERE VoteTypeId=2
)

SELECT Days, COUNT(*) FROM votes_cte
GROUP BY Days
ORDER BY Days

--VoteTypeId:
--1 = AcceptedByOriginator
--2 = UpMod (AKA upvote)
--3 = DownMod (AKA downvote) 

--DATEDIFF returns the number of times the given period changed (for 23:59:00 and 00:01:00 the next day it returns 1 days, for 2018-12-31 and 2019-01-01 it returns 1 months/years)

Enter Parameters

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