Closed Questions by Week

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

WITH cte 
     AS (SELECT Dateadd(week, Datepart(week, creationdate), '1/1/' + 
                   CAST(YEAR(creationdate) AS 
                                CHAR(4))) 
                    cdate, 
                CASE 
                  WHEN closeddate IS NOT NULL THEN 1 
                  ELSE 0 
                END closed, 
                id 
         FROM   posts 
         WHERE  posttypeid = 1) 
SELECT cdate, 
       ( CAST(SUM(closed) AS DECIMAL (15, 4)) / 
         CAST(COUNT(id)AS DECIMAL (15, 4)) )  closeRate
FROM   cte 
GROUP  BY cdate 
ORDER  BY cdate

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached