select n.TagName as Tag, row_number() over (order by n.Nu...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Ask Ubuntu

Q&A for Ubuntu users and developers

select 
n.TagName as Tag,
row_number() over (order by n.Num desc) as Rank,
n.Num as NumberOfTimesTagged
from
    (select count(PostId) as Rate, TagName
    from
    Tags, PostTags, Posts
    where Tags.Id = PostTags.TagId and Posts.Id = PostId
    and Posts.CreationDate < '2018-01-01'
    and Posts.CreationDate > '2016-12-31'
    group by TagName) 
as r
INNER JOIN
(select count(PostId) as Num, TagName
from
  Tags, PostTags, Posts
where Tags.Id = PostTags.TagId and Posts.Id = PostId
group by TagName)
as n ON r.TagName = n.TagName
order by n.Num desc
;

Enter Parameters

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