Percent closed by week

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

select cast (dateadd(week, datediff(week, getdate(), q.CreationDate), getdate()) as DATE) Week,
       100.0*count(ClosedDate)/count(q.Id) percent_closed,
       100.0*count(case when Score < 0 then 1 end)/count(q.Id) percent_downvoted,
       100.0*count(case when Score < 0 or ClosedDate is not null then 1 end)
            /count(q.Id) percent_rejected
from Posts q
where q.PostTypeId = 1
group by DATEDIFF(week, getdate(), q.CreationDate)
order by DATEDIFF(week, getdate(), q.CreationDate)

Enter Parameters

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