Number of unique users on Answers posted per month for a given tag and time duration

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

select count(DISTINCT temp_p.OwnerUserId) AS USERS,
       DATENAME(mm, temp_p.CreationDate) AS MONTH_NAME,
       DATENAME(yyyy, temp_p.CreationDate) AS YEAR,
       MONTH(temp_p.CreationDate) AS MONTH_NUM
 from  
(
select  p2.OwnerUserId, p2.CreationDate
  from  Posts p2, PostTypes ptypes2 
 where  p2.posttypeid = ptypes2.id
   and  p2.CreationDate >= '##startdate##'
   and  p2.CreationDate <= '##enddate##'
   and  ptypes2.id = 2
   and  p2.parentid in
     (  select  p3.id
          from  Posts p3, PostTags ptags3, Tags t3, PostTypes ptypes3 
         where  p3.posttypeid = ptypes3.id
           and  ptypes3.id = 1
           and  p3.id = ptags3.postid 
           and  ptags3.tagid = t3.id 
           and  t3.tagname = '##TagName##'
     )
) temp_p
group by DATENAME(yyyy, temp_p.CreationDate), MONTH(temp_p.CreationDate), DATENAME(mm, temp_p.CreationDate)
order by DATENAME(yyyy, temp_p.CreationDate) ASC, MONTH(temp_p.CreationDate) ASC, DATENAME(mm, temp_p.CreationDate) ASC

Enter Parameters

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