SELECT COUNT(q.Id) AS 'Total Self-Answers', COUNT(CASE WH...

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
COUNT(q.Id) AS 'Total Self-Answers',
COUNT(CASE WHEN q.Score < 0 THEN 1 ELSE NULL END) AS '<0 Score',
COUNT(CASE WHEN q.Score = 0 THEN 1 ELSE NULL END) AS '0 Score',
COUNT(CASE WHEN q.Score > 0 THEN 1 ELSE NULL END) AS '>0 Score'
FROM Posts q
JOIN Posts a ON a.ParentId = q.Id AND a.OwnerUserId = q.OwnerUserId
WHERE a.PostTypeId = 2 AND q.PostTypeId = 1

SELECT 
COUNT(Id) AS 'Total'
FROM Posts

Enter Parameters

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