Please login or register to vote for this query.

(click on this box to dismiss)

select from Tags t inner join ()s on t.id=s.

Motor Vehicle Maintenance and Repair Meta

Q&A about the site for mechanics and DIY enthusiast owners of cars, trucks, and motorcycles

select top 100000 * 
into #LPosts
from Posts;

with s as(select FORMAT(p.CreationDate, 'yyyy.MM') as MonthYear, pt.TagId as TagId, count(TagId) as CountTags
from PostTags pt
inner join
#LPosts p
on p.Id=pt.PostId
group by FORMAT(p.CreationDate, 'yyyy.MM'), pt.TagId)

select t.Id, MAX(s.MonthYear) as YearMonth
from(select s.TagId, s.MonthYear
    from s inner join (select TagId, MAX(CountTags) as MaxCount from s group by TagId) sm
    on s.TagId=sm.TagId
    where s.CountTags=sm.MaxCount) s
    inner join
    Tags t
    on s.TagId=t.Id
group by t.Id
order by t.Id;

Enter Parameters

Switch to main site
loading Hold tight while we fetch your results