Posts (Answers) based on a given tag and a given 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(*) AS "NUMBER_OF_ANSWERS", 
       DATENAME(mm, p2.LastActivityDate) AS MONTH_NAME,
       DATENAME(yyyy, p2.LastActivityDate) AS YEAR,
       MONTH(p2.LastActivityDate) AS MONTH_NUM
from   Posts p2, PostTypes ptypes2
where  p2.posttypeid = ptypes2.id
and    ptypes2.id = 2
and    p2.parentid in
      (
        select p1.id
        from Posts p1, PostTags ptags1, Tags t1, PostTypes ptypes1 
        where p1.posttypeid = ptypes1.id
          and ptypes1.id = 1
          and p1.id = ptags1.postid 
          and ptags1.tagid = t1.id 
          and t1.tagname = '##TagName##'
      )
and   p2.creationdate >= '##startdate##'
and   p2.creationdate <= '##enddate##'
group by DATENAME(yyyy, p2.LastActivityDate), MONTH(p2.LastActivityDate), DATENAME(mm, p2.LastActivityDate)
order by DATENAME(yyyy, p2.LastActivityDate) ASC, MONTH(p2.LastActivityDate) ASC, DATENAME(mm, p2.LastActivityDate) ASC

Enter Parameters

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