I am looking for a data explorer query that I could run on a site and get the number of votes (up and down if possible) over all Questions and Answers (displayed separately)?

I am interested in knowing the Q / A vote ratio for a couple of beta sites compared to other more established ones.


Like this?

  -- the kruft here is just for pretty output formatting
  IIF(p.PostTypeId = 1, 'Questions', 'Answers') AS [Post Type],
  IIF(v.VoteTypeId = 2, 'Up Votes', 'Down Votes') AS [Vote Type],
  COUNT(*) AS [Count]
  Posts p INNER JOIN Votes v ON p.Id = v.PostId
  -- open questions only (roughly):
  p.ClosedDate IS NULL 
  -- questions (1) and answers (2) only:
  AND (p.PostTypeId = 1 OR p.PostTypeId = 2) 
  -- upvotes (2) and downvotes (3) only
  AND (v.VoteTypeId = 2 OR v.VoteTypeId = 3) 
  -- group into questions + answers and upvotes + downvotes for counting
  p.PostTypeId, v.VoteTypeId

On SO:

Post Type Vote Type  Count    
--------- ---------- -------- 
Questions Up Votes   15355558 
Answers   Up Votes   35223709 
Questions Down Votes 1141576  
Answers   Down Votes 1058351  

(4 row(s) returned)

Remove the ClosedDate condition if you'd like to include all questions and answers.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .