Number of up- and downvotes for a single post

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT SUM(CASE VoteTypeId WHEN 2 THEN 1 ELSE 0 END) AS 'Upvotes',
       SUM(CASE VoteTypeId WHEN 3 THEN 1 ELSE 0 END) AS 'Downvotes'
  FROM Votes
  WHERE PostId = ##postID:int##

Enter Parameters

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