with upvoted as ( select posts.Id as PostId from posts i...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Webmasters

Q&A for pro webmasters

-- Enter Query Title
-- Enter Query Description

with upvoted as (
select
  posts.Id as PostId
from
  posts inner join
  votes on posts.Id = votes.PostId
where votes.VoteTypeId = 2 -- upvotes
  and posts.PostTypeId = 2 -- answers
group by posts.Id
)

select
  users.Id,
  count(posts.Id) as [Posts],
  count(upvoted.PostId) as [Upvoted Posts]
  --[Upvoted Posts] * 100.0 / [Posts] as [Upvoted %]
from
  users   left outer join
  posts   on users.Id = posts.Id
          left outer join
  upvoted on posts.Id = upvoted.PostId
where
  posts.PostTypeId = 2
group by users.Id
--having count(posts.Id) >= 5
--order by [Upvoted %] desc;

Enter Parameters

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