Q&A for professional and enthusiast programmers
SELECT CASE WHEN qora.t = 1 THEN 'Q' ELSE 'A' END as 'type', CASE WHEN uord.t = 2 THEN 'up' ELSE 'down' END as 'vote', COUNT(p.Id) as 'num posts', COUNT(v.Id) as 'effective', COUNT(f.Id) as 'anonymous' FROM (VALUES (1), (2)) as qora(t) CROSS JOIN (VALUES (2), (3)) as uord(t) INNER JOIN Posts as p on p.PostTypeId = qora.t LEFT OUTER JOIN Votes as v ON (p.Id = v.PostId AND v.VoteTypeId = uord.t) LEFT OUTER JOIN PostFeedback as f ON (p.ID = f.PostId AND f.VoteTypeId = uord.t) -- minid: minimum post ID to consider WHERE p.Id >= ##minid:int## GROUP BY qora.t, uord.t ORDER BY qora.t, uord.t ASC