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 tmp 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(tmp.MonthYear) as YearMonth from
(select tmp.TagId, tmp.MonthYear from tmp 
inner join 
(select TagId, MAX(CountTags) as MaxCount from tmp 
group by TagId) abc
on tmp.TagId=abc.TagId
where tmp.CountTags=abc.MaxCount) tmp
inner join
Tags t on tmp.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