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;

Motor Vehicle Maintenance and Repair Meta

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

select top 1000000 *into #LPosts from Posts;

with tmp as(select FORMAT(r.CreationDate, 'yyyy.MM') as MY, q.TagId as TagId, count(TagId) as CT from PostTags q
inner join
#LPosts r on r.Id=q.PostId
group by FORMAT(r.CreationDate, 'yyyy.MM'), q.TagId)

select t.TagName as Tag, MAX(tmp.MY) as YearMonth from
(select tmp.TagId, tmp.MY from tmp 
inner join 
(select TagId, MAX(CT) as MC from tmp 
group by TagId) abc
on tmp.TagId=abc.TagId
where tmp.CT=abc.MC) tmp
inner join
Tags t on tmp.TagId=t.Id
group by t.TagName
order by Tag asc;

Enter Parameters

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