Q&A for people who build and repair bicycles, people who train cycling, or commute on bicycles
SET SHOWPLAN_TEXT ON GO WITH UpvotedPosts AS (SELECT p.Id FROM Posts p WHERE p.PostTypeId = 1 AND -- question p.Id IN (SELECT v.PostId From Votes v WHERE v.VoteTypeId = 2) ) SELECT COUNT(*) as [Upvoted posts] FROM UpvotedPosts u --COUNT(Downvoted) as [Downvoted posts] --COUNT(IIF(PostTypeId = 1 AND Upvoted = 1, 1, NULL)) as [Upvoted Qstns] --SUM(IsQuestion * Downvoted) as [Downvoted Qstns], --SUM(IsAnswer * Upvoted) as [Upvoted Answers], --SUM(IsAnswer * Downvoted) as [Downvoted Answers]