Posts (Questions and Answers) based on a given tag and 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 DATENAME(yyyy, p.LastActivityDate) AS YEAR,
       DATENAME(mm, p.LastActivityDate) AS MONTH,
       MONTH(p.LastActivityDate) AS MONTH_NUM,
       count(*) AS Total
from Posts p, PostTags ptags, Tags t, PostTypes ptypes 
where p.posttypeid = ptypes.id
  and ptypes.id in (1,2)
  and p.id = ptags.postid 
  and ptags.tagid = t.id 
  and t.tagname = '##TagName##'
  and p.creationdate >= '##startdate##'
  and p.creationdate <= '##enddate##'
group by DATENAME(yyyy, p.LastActivityDate), MONTH(p.LastActivityDate), DATENAME(mm, p.LastActivityDate)
order by DATENAME(yyyy, p.LastActivityDate) ASC, MONTH(p.LastActivityDate) ASC, DATENAME(mm, p.LastActivityDate) ASC

Enter Parameters

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