User's percent closed questions (Q >= 50)

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

CREATE TABLE #userQs (userid int, asked int);

INSERT #userQs (userid, asked)
SELECT q.OwnerUserid, COUNT(q.Id)
FROM Posts Q 
WHERE q.PostTypeId = 1
GROUP BY q.OwnerUserId

CREATE TABLE #userClosedQs (userid int, closed int);
INSERT #userClosedQs (userid, closed)
SELECT q.OwnerUserid, COUNT(q.Id)
FROM Posts Q 
WHERE q.PostTypeId = 1
AND q.ClosedDate IS NOT NULL
GROUP BY q.OwnerUserId


select #userQs.userid as [User Link], asked, closed,
  100 * closed / asked AS "Percent Closed"
from #userQs
JOIN #userClosedQs
on #userQs.userid = #userClosedQs.userid
where asked >= 50
ORDER BY "Percent Closed" DESC

Enter Parameters

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