answered question percentage for the last M months

2

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow на русском

Вопросы и ответы для программистов

-- 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

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