Preguntas y respuestas para programadores y profesionales de la informática
-- 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