Q&A for users, experts, and developers of the Tezos blockchain project
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 in ( 101337, 111386, 120131, 138432, 145025, 149848, 16861, 172739, 184112, 211169, 252180, 277044, 29399, 311243, 34079, 34573544, 4065657, 454048, 459248, 517575, 55643, 563037, 5925954, 6190381, 6463152, 942011) GROUP BY v.CreationDate ORDER BY v.creationdate asc -- ORDER BY UpVotes DESC