select top 50 -- only the top 50 users p.lasteditoruserid...

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 top 50 -- only the top 50 users
       p.lasteditoruserid as [User Link]
     , sum(case 
           when posttypeid = 1 then 1  -- Questions
           else 0
           end
       ) as questions
     , sum(case 
           when posttypeid = 2 then 1  -- Answers
           else 0
           end
       ) as answers
     , count(*) as total     -- rowcount per user
from posts p
where posttypeid in (1,2) -- only questions and answers (exclude wiki's)
and p.lasteditoruserid is not null
group by p.lasteditoruserid
order by count(*) desc

Enter Parameters

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