Answerers per year

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

with answerers_year as
(
select u.Id UserId, year(a.CreationDate) year
from Users u
     join PostsWithDeleted a on a.OwnerUserId = u.Id and a.PostTypeId = 2
where a.Score > 0
group by u.Id, year(a.CreationDate)
),
questions_year as
(
select count(distinct q.Id) questions, year(q.CreationDate) year
from PostsWithDeleted q
where q.PostTypeId = 1
group by year(q.CreationDate)
)

select a.year, 
       count(distinct UserId) answerers, 
       min(questions) questions
from answerers_year a
     join questions_year q on q.year = a.year
group by a.year
order by a.year

Enter Parameters

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