answered/unanswered year over year

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 ratio 
AS(
  SELECT
    DATEADD(YEAR, DATEDIFF(YEAR, 0, CreationDate), 0) AS AI, 
    COUNT(DISTINCT Posts.Id) AS Count,
    SUM(CASE WHEN Posts.AnswerCount > 0 THEN 1 ELSE 0 END) AS answered
  FROM Posts
  WHERE PostTypeId = 1 AND CreationDate > '2012-01-01'
  GROUP BY DATEADD(YEAR, DATEDIFF(YEAR, 0, CreationDate), 0)
)
SELECT 
  AI as 'Year',
  Count as 'Total Questions',
  answered*100 / Count as '% Answered'
From ratio
Order by Year DESC

Enter Parameters

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