Up/down vote breakdown for a post

0

Please login or register to vote for this query.

(click on this box to dismiss)

Physics Meta

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

SELECT
  Posts.Id AS [Post Link],
  Posts.Score AS 'Score',
  COUNT(CASE WHEN Votes.VoteTypeId = 2 THEN 1 END) AS 'UpVotes',
  COUNT(CASE WHEN Votes.VoteTypeId = 3 THEN 1 END) AS 'DownVotes'
FROM Posts
JOIN Votes ON Votes.PostId = Posts.Id
WHERE Posts.Id = ##post:int##
   -- post: Post Id to query
  AND (Votes.VoteTypeId = 2 OR Votes.VoteTypeId = 3)
GROUP BY Posts.Id, Posts.Score

Enter Parameters

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