Number of Views for all posts given a specific tag and duration

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow на русском Meta

Вопросы и ответы о сайте для программистов

select    COUNT(p1.Id) "# Questions",
          SUM(p1.viewcount) "# Views",
          SUM(p1.AnswerCount) "#Answers",
          DATENAME(mm, p1.CreationDate) "Month",
          DATENAME(yyyy, p1.CreationDate) "Year"
 
  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    p1.CreationDate >= '##startdate##'
   and    p1.CreationDate <= '##enddate##'
group by  DATENAME(yyyy, p1.CreationDate), MONTH(p1.CreationDate), DATENAME(mm, p1.CreationDate)
order by  DATENAME(yyyy, p1.CreationDate) DESC, MONTH(p1.CreationDate) DESC
--order by  YEAR(p1.CreationDate) DESC, MONTH(p1.CreationDate) DESC

Enter Parameters

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