Given tag frequency

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

-- Most popular StackOverflow tags till current date

Declare @month int, @year int

set @month = '6' - 1
set @year = '2013'

if @month = 0  --january
begin
  Set @month = 12
  Set @year = @year - 1
End

select 
       num.TagName as Tag,
       rate.Rate as QuestionsInMay,
       num.Num as QuestionsTotal

from

(select count(PostId) as Rate, TagName
from
  Tags, PostTags, Posts
where Tags.Id = PostTags.TagId and Posts.Id = PostId and Tags.TagName LIKE '%##TagName##%'
and datepart(month, Posts.CreationDate) = @month
and datepart(year, Posts.CreationDate) = @year
group by TagName) as rate

INNER JOIN

(select count(PostId) as Num, TagName
from
  Tags, PostTags, Posts
where Tags.Id = PostTags.TagId and Posts.Id = PostId
group by TagName
having count(PostId) > 800)
as num ON rate.TagName = num.TagName
order by rate.rate desc
;

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results