SELECT TOP 100 Id AS [User Link], P.C AS [Great Answers],...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

-- Enter Query Title
-- Enter Query Description
SELECT TOP 100
    Id AS [User Link],
    P.C AS [Great Answers],
    CASE
        WHEN (SELECT Count(*)                 
             FROM Posts
             WHERE PostTypeId = 2
             AND OwnerUserId = U.Id) > 0 THEN P.C / 
             (SELECT TC = Count(*)                 
             FROM Posts
             WHERE PostTypeId = 2
             AND OwnerUserId = U.Id)
        ELSE 0
    END AS [Great Answer Ratio]
FROM Users U
INNER JOIN
    (SELECT
    OwnerUserId, C = Count(*)
    FROM Posts
    WHERE Score >= 10
    GROUP BY OwnerUserId) P
ON U.id = P.OwnerUserId
ORDER BY [Great Answer Ratio] Desc

Enter Parameters

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