Count upvotes

0

Please login or register to vote for this query.

(click on this box to dismiss)

Genealogy and Family History Meta

Q&A about the site for expert genealogists and people interested in genealogy or family history

select PostId, SUM(CASE WHEN a.VoteTypeId = 2 THEN 1 ELSE 0 END) AS UpVotes,
  SUM(CASE WHEN a.VoteTypeId = 3 THEN 1 ELSE 0 END) AS DownVotes
FROM votes a
  INNER JOIN posts b
    ON 
      a.PostId = b.Id
      AND b.PostTypeId IN (1,2) 
WHERE 
 VoteTypeId IN (2,3) 
group by PostId

Enter Parameters

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