Questions self-answered after someone else with a decent answer length, by reputation

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

select count(distinct q.id) as Questions
     , count(distinct u.id) as Users
     , case when u.reputation <= 11 then '1 - 11'
            when u.reputation <= 200 then '11 - 200'
            when u.reputation <= 1000 then '200 - 1k'
            when u.reputation <= 3000 then '1k - 3k'
            when u.reputation <= 5000 then '3k - 5k'
            when u.reputation <= 10000 then '5k - 10k'
            when u.reputation <= 20000 then '10k - 20k'
            when u.reputation > 20000 then '20k +'
        end as [Reputation "level"]
  from posts q
  join posts a
    on q.id = a.parentid
  join users u
    on q.owneruserid = u.id
  join ( select owneruserid, count(*) as ct
           from posts
          group by owneruserid
          ) p
    on u.id = p.owneruserid
 where q.posttypeid = 1
   and a.posttypeid = 2
   and q.closeddate is null
   and ( len(a.body) >= 200
         or ( len(a.body) < 200
             and a.score >= 2 
             )
        )
   and DATEPART(yyyy, q.CreationDate) = 2012
   and a.owneruserid = q.owneruserid
   and datediff(DD, q.CreationDate, a.creationDate) < 1
   and a.score >= 1
   and q.score >= 0
   and not exists ( select 1 
                      from posts
                     where parentid = a.parentid
                       and id <> a.id
                       and score > 0
                       and CreationDate < a.CreationDate
                           )
 group by case when u.reputation <= 11 then '1 - 11'
            when u.reputation <= 200 then '11 - 200'
            when u.reputation <= 1000 then '200 - 1k'
            when u.reputation <= 3000 then '1k - 3k'
            when u.reputation <= 5000 then '3k - 5k'
            when u.reputation <= 10000 then '5k - 10k'
            when u.reputation <= 20000 then '10k - 20k'
            when u.reputation > 20000 then '20k +'
        end

Enter Parameters

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