Question 3

0

Please login or register to vote for this query.

(click on this box to dismiss)

The Workplace Meta

Q&A about the site for members of the workforce navigating the professional setting

WITH UserComments AS (
    SELECT 
        C.UserId, 
        COUNT(DISTINCT C.PostId) AS CommentCount
    FROM Comments C
    GROUP BY C.UserId
    HAVING COUNT(DISTINCT C.PostId) >= 10
), 

CorrectAnswers AS (
    SELECT  
        A.OwnerUserId AS UserId
    FROM Posts Q 
    JOIN Posts A ON Q.AcceptedAnswerId = A.Id
    WHERE Q.PostTypeId = 1 
      AND A.PostTypeId = 2
)
SELECT 
    U.Id, U.DisplayName, 
    COUNT(CA.UserId) AS CorrectAnswerCount
FROM Users U
JOIN CorrectAnswers CA ON U.Id = CA.UserId
JOIN UserComments UC ON U.Id = UC.UserId
WHERE U.CreationDate < DATEADD(month, -6, GETDATE())
GROUP BY U.Id, U.DisplayName
ORDER BY CorrectAnswerCount DESC;

Enter Parameters

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