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(Id, WinRate, TrueAnswer, Answer) as(
select tmp1.Id as Id, (cast(tmp1.TrueAnswer as float)/tmp2.Answer * 100) as WinRate, tmp1.TrueAnswer as TrueAnswer, tmp2.Answer as Answer from
(select a.OwnerUserId as Id, count(a.OwnerUserId) as TrueAnswer from 
(select * from #LPosts where PostTypeId=2) a 
inner join
(select * from #LPosts where PostTypeId=1) q on a.Id=q.AcceptedAnswerId
group by a.OwnerUserId) tmp1
inner join
(select OwnerUserId as Id, count(OwnerUserId) as Answer from  #LPosts
where PostTypeId=2
group by OwnerUserId
having count(OwnerUserId)>20) tmp2 on tmp1.Id=tmp2.Id)

select * from Users u 
inner join
(select *from tmp where WinRate=(select MAX(WinRate) from 
tmp))tmp on u.Id=tmp.Id;

Enter Parameters

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