Users with multiple active unanswered questions

0

Please login or register to vote for this query.

(click on this box to dismiss)

Code Review

Q&A for peer programmer code reviews

-- Users with multiple active unanswered questions

with unanswered as (
  select
    posts.Id as PostId
  from
    posts
  where posts.PostTypeId = 1            -- questions
    and posts.OwnerUserId is not null   -- user exists
    and posts.AcceptedAnswerId is null  -- no answer selected
    and posts.ClosedDate is null        -- still open
  group by posts.Id
),

percentages as (
  select
    users.Id as UserId,
    count(posts.Id) as Questions,
    count(unanswered.PostId) as UnansweredQuestions,
    (count(unanswered.PostId) * 100.0 / count(posts.Id)) as UnansweredPct
  from
    users left outer join
    posts on users.Id = posts.OwnerUserId
          left outer join
    unanswered on posts.Id = unanswered.PostId
  where
    posts.PostTypeId = 1
  group by
    users.Id
)

select top ##MaxRowsToSelect:int?100##
  UserId as [User Link],
  UnansweredQuestions as [Unanswered Questions],
  Questions,
  round(UnansweredPct, 1) as [Unanswered %]
from percentages
where UnansweredPct > ##MinUnansweredPct:int?40##
  and UnansweredQuestions > ##MinUnansweredQuestions:int?10##
order by UnansweredPct desc;

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results