Number of posts with upvotes vs. downvotes

0

Please login or register to vote for this query.

(click on this box to dismiss)

Bicycles

Q&A for people who build and repair bicycles, people who train cycling, or commute on bicycles

WITH PostData AS (SELECT
  PostId,
  MAX(case VoteTypeId when 2 then 1 else null end) as Upvoted,
  MAX(case VoteTypeId when 3 then 1 else null end) as Downvoted
FROM Votes
GROUP BY PostId, VoteTypeId)

SELECT * FROM PostData

--SELECT
--  COUNT(case VoteTypeId when 2 then 1 else null end) as [Posts with upvotes],
--  COUNT(case VoteTypeId when 3 then 1 else null end) as [Posts with downvotes]

Enter Parameters

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