Q&A for professional and enthusiast programmers
SELECT sum(case when a.Score > 0 then 1 else 0 end) as Up, sum(case when a.Score < 0 then 1 else 0 end) as Down, sum(case when a.Score = 0 then 1 else 0 end) as Neutral FROM Posts p inner join Posts a on a.ParentId = p.Id WHERE p.ClosedDate is not null GROUP BY p.Id ORDER BY Up