select top 25[owneruserid] as [User Link], * from ( select

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

select top 25[owneruserid] as [User Link], *
from (

select
  owneruserid,
  rn=row_number() over (partition by owneruserid order by creationdate),
  creationdate,
  sum(bounty) bounty,
  sum(coalesce(accepted+bounty,accepted,bounty)) immune,
  (select min(a) from (
     select sum(rep) a
     union all
     select 200) x) as votes_capped
from
(
select
  p.owneruserid,
  v.creationdate,
  case votetypeid
      when 1 then 15
      end accepted,
  case votetypeid
      when 8 then -bountyamount
      when 9 then bountyamount
      end bounty,
  case votetypeid
      when 2 then 10
      when 3 then -2
      else 0
      end rep
from votes v
inner join posts p on p.id = v.postid
inner join users u on u.id = p.owneruserid
where v.votetypeid in (1,2,3,8,9)
  and p.communityowneddate is null
  and u.reputation >= 1000
) x
group by owneruserid, creationdate
) y
order by immune+ votes_capped desc

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached