select owneruserid as [User Link] , sum(case when posttyp...

0

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 owneruserid as [User Link]
     , sum(case when posttypeid = 1 then 1 else 0 end) as q
     , sum(case when posttypeid = 2 then 1 else 0 end) as a
from posts 
where 
posttypeid in (1,2)
and owneruserid is not null
-- and owneruserid in (39677, 578411)
group by owneruserid
having sum(case when posttypeid = 1 then 1 else 0 end) > ##q##
   and sum(case when posttypeid = 2 then 1 else 0 end) < ##a##

Enter Parameters

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