Q&A for researchers, developers, and users of Tor
SELECT --TOP 20 --v. postid, v.CreationDate, COUNT( Case when v.VoteTypeId = 2 then 1 end) AS UpVotes, COUNT( Case when v.VoteTypeId = 3 then 1 end) AS DownVotes, SUM( Case when v.VoteTypeId =2 then 1 when v.VoteTypeId = 3 then -1 end) AS NetVotes -- COUNT(*) AS TotalVotes FROM Votes as v --INNER JOIN PostTags ON PostTags.TagId = Tags.id --INNER JOIN Posts ON Posts.ParentId = PostTags.PostId INNER JOIN Posts ON v.PostId = Posts.Id and (v.VoteTypeId = 2 or v.VoteTypeId=3) WHERE -- Posts.OwnerUserId = @UserId -- Posts.Id = 60174 Posts.Id=##postid## GROUP BY v.CreationDate ORDER BY v.creationdate asc -- ORDER BY UpVotes DESC