Answering badges

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

with user_answers as (
  select OwnerUserId, count(*) number_answered
  from Posts
  where Score > 0
        and PostTypeId = 2
        and OwnerUserId is not null
  group by OwnerUserId
),

answering_badges as (
  select case 
           when number_answered >= ##gold?50## then 1
         end gold,
         case
           when number_answered >= ##silver?10## then 1
         end silver,
         case
           when number_answered >= ##bronze?1##  then 1
         end bronze,
         case
           when number_answered is null  then 1
         end none
  from user_answers
       right join Users on OwnerUserId = Id
)

select count(*) users, 
       sum(gold) gold, 
       sum(silver) silver, 
       sum(bronze) bronze, 
       sum(none) none
from answering_badges

Enter Parameters

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