Count within a case statment

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
   OwnerUserId
  ,MAX(OwnerDisplayName)
  ,MAX(SCORE)
  ,SUM(CASE
        WHEN AcceptedAnswerId IS NOT NULL
        AND ViewCount > 10
        THEN 1
        ELSE 0
       END) AS Foo
FROM Posts
GROUP BY OwnerUserId;

Enter Parameters

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