Posts having 100, or more, downvotes

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

WITH highVotePosts AS (
    SELECT      v.PostId,
                SUM (CASE WHEN v.VoteTypeId = 2 THEN 1 ELSE 0 END) AS [Up votes],
                SUM (CASE WHEN v.VoteTypeId = 3 THEN 1 ELSE 0 END) AS [Dwn votes]
    FROM        Votes v
    GROUP BY    v.PostId
    HAVING      SUM (CASE WHEN v.VoteTypeId = 3 THEN 1 ELSE 0 END) > 99
)
SELECT      hvp.PostId as [Post Link],
            hvp.[Dwn votes],
            hvp.[Up votes]
FROM        highVotePosts hvp
--WHERE       LEN (CAST (hvp.[Dwn votes] AS varchar(15) ) )  >=  LEN (CAST (hvp.[Up votes] AS varchar(15) ) )
ORDER BY    hvp.[Dwn votes] DESC,
            hvp.[Up votes] DESC

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results