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 COUNT(Upvoted) as [Posts with upvotes], COUNT(Downvoted) as [Posts with downvotes] FROM PostData