Most popular StackOverflow tags in a month

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 in 28 days

DECLARE @MonthBegin datetime = ##MonthBegin:string##;
DECLARE @MonthEnd datetime = @MonthBegin + 28;

SELECT num.TagName AS Tag,
       row_number() OVER (ORDER BY rate.Rate DESC) AS MonthRank,
       row_number() OVER (ORDER BY num.Num DESC) AS TotalRank,
       rate.Rate AS QuestionsInMonth,
       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 Posts.CreationDate <= @MonthEnd
      and Posts.CreationDate >= @MonthBegin
    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 sites:
loading Hold tight while we fetch your results