Postgres

0

Please login or register to vote for this query.

(click on this box to dismiss)

select * from Users u join (select top 10 a.OwnerUserId as Id, count(a.OwnerUserId) as TrueAnswer from (select * from Posts where PostTypeId=2) a join (select * from Posts where PostTypeId=1) q on a.Id=q.AcceptedAnswerId group by a.OwnerUserId order by TrueAnswer desc) s on u.Id=s.Id order by s.TrueAnswer desc;

Stack Overflow

Q&A for professional and enthusiast programmers

select top 1000000 *
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.TagName as Tag, 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.TagName
order by Tag asc;

Enter Parameters

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