Users who've asked more questions than answers

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

-- 1 is question
-- 2 is answer

with q_and_as as (
  select 
    *,
    case when posttypeid = 1 then 1 else null end as isq,
    case when posttypeid = 2 then 1 else null end as isa
  from posts
  where posttypeid = 1 or posttypeid = 2
),
  
  

user_posts as (select 
  owneruserid,
  owneruserid as [User Link],
  sum(isq) as questions,
  sum(isa) as answers,
  count(*) as posts
from q_and_as
group by owneruserid
)

select top 20 * from user_posts
where questions > answers
order by posts desc

Enter Parameters

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