SELECT sum(case when a.Score > 0 then 1 else 0 end) as Up...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

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

Enter Parameters

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