H-index (based on duplicates) ranking

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

select row_number() over (order by max(H.LinkScore) desc) as [#]
  , H.OwnerUserId as [User Link], max(H.LinkScore) as HIndex
from (
  select S.OwnerUserId, S.LinkScore
    , sum(S.NumAnswers)
      over (partition by S.OwnerUserId order by S.LinkScore desc rows unbounded preceding)
      as NumAnswersCumul
  from (
    select P.OwnerUserId
      , L.LinkScore
      , count(*) as NumAnswers
    from Posts P
    inner join (
      select PL.RelatedPostId, count(*) as LinkScore
      from PostLinks PL
      inner join Posts PS on PS.Id = PL.PostId -- removing deleted
      where PL.LinkTypeId = 3
      group by PL.RelatedPostId
      ) L on L.RelatedPostId = P.ParentId
    where P.PostTypeId = 2
      and L.LinkScore >= 5
      and P.OwnerUserId is not null
    group by P.OwnerUserId, L.LinkScore
    ) S
  ) H
where H.NumAnswersCumul >= H.LinkScore
group by H.OwnerUserId
order by HIndex desc

Enter Parameters

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