answered question percentage for the last M months


Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

-- answered question has accepted or upvoted answer

declare @months_ago DATETIME = DateAdd(month, -##months:int##, GETUTCDATE())

-- 1 - question
-- 2 - answer
select 100*cast((select count(distinct Q.Id) from Posts Q, Posts A where A.ParentId = Q.Id and Q.CreationDate > @months_ago and (A.Score > 0 or Q.AcceptedAnswerId = A.Id)) as float) / (select count(*) from Posts where PostTypeId = 1 and CreationDate > @months_ago) as [answer ratio]

Enter Parameters

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