Most popular StackOverflow tags in a given period

0

Please login or register to vote for this query.

(click on this box to dismiss)

Audio-Video Production Meta

Q&A about the site for engineers, producers, editors, and enthusiasts spanning the fields of video, and media creation

--I'm using date instead of datetime here to force an error if the user
--enters a date without the quotes.
DECLARE @StartDate date = ##StartDate##
DECLARE @EndDate date = ##EndDate##

-- Most popular StackOverflow tags in a given period

select 
       num.TagName as Tag,
       row_number() over (order by rate.Rate desc) as [Period Rank],
       row_number() over (order by num.Num desc) as [Total Rank],
       rate.Rate as [Questions In Period],
       num.Num as [Questions Total]

from

(select count(PostId) as Rate, TagName
from
  Tags, PostTags, Posts
where Tags.Id = PostTags.TagId and Posts.Id = PostId
and Posts.CreationDate < @EndDate
and Posts.CreationDate > @StartDate
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