Work in progress

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

DECLARE @Users     TABLE
    (
    UserId         INT PRIMARY KEY,
    QuestionCount  INT
    )

INSERT INTO
    @Users
    
SELECT
    Users.Id                         AS UserId,
    COUNT( DISTINCT Question.Id )    AS QuestionCount
    
FROM
    Users
    
    INNER JOIN
    Posts                            AS Question
    ON  Users.Id                     = Question.OwnerUserId
    
WHERE
        Question.PostTypeId          = 1 --questions
    AND Users.CreationDate           > '1/1/2010'
    AND Question.AnswerCount         > 0
    
GROUP BY
    Users.Id
    
HAVING
    COUNT( DISTINCT Question.Id )    > 5 



DECLARE @Unaccepted     TABLE
    (
    UserId              INT PRIMARY KEY,
    UnacceptedCount     INT
    )

INSERT INTO
    @Unaccepted
    
SELECT
    Users.UserId                     AS UserId,
    Users.QuestionCount              AS UnacceptedCount
    
FROM
    @Users                           AS Users
    
    INNER JOIN
    Posts                            AS Unaccepted
    ON  Users.UserId                 = Unaccepted.OwnerUserId
    
WHERE
        Unaccepted.PostTypeId        = 1 --questions
    AND Unaccepted.AcceptedAnswerId  IS NULL
    
GROUP BY
    Users.UserId,
    Users.QuestionCount

HAVING
    COUNT( Unaccepted.Id )           = Users.QuestionCount



SELECT
    Users.UserId           AS [User Link],
    Users.QuestionCount    AS [Question Count]
    
FROM
    @Users                 AS Users
    
    INNER JOIN
    @Unaccepted            AS Unaccepted
    ON Users.UserId        = Unaccepted.UserId

WHERE
    Users.QuestionCount    = Unaccepted.UnacceptedCount

ORDER BY
    Users.QuestionCount    DESC

Enter Parameters

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