プログラマーとプログラミングに熱心な人々のための質問と回答
; with askersaccepted_cte AS (SELECT q.OwnerUserId AS uid, q.OwnerDisplayName AS udn, COUNT(q.Id) AS QCount, SUM(CASE WHEN (q.AnswerCount>0) THEN 1 ELSE 0 END) AS Acount, COUNT(q.AcceptedAnswerId) AS AccCount FROM Posts q GROUP BY q.OwnerUserId, q.OwnerDisplayName ) SELECT TOP(##num?500##) uid AS [User Link], udn AS [Display Name], AccCount AS [Questions with accepted answer], ACount AS [Questions with at least one answer], QCount AS [All Questions], ROUND(AccCount*100.0/ACount,2) AS percentage FROM askersaccepted_cte WHERE (ACount>=##min?10##) --restrict to users with non-negligible number of answered questions ORDER BY AccCount DESC