Underdog

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

select 
  [Total Questions with Accepted] = count(distinct q.Id),
  [Total Accepted Score < Other Score] = count(distinct case when aa.Score < oa.Score then q.Id end),
  [Total Neg Accepted Score < Other Score] = count(distinct case when aa.Score < 0 and aa.Score < oa.Score then q.Id end),
  [Total Neg Accepted Score < Other Score Pos] = count(distinct case when aa.Score < 0 and oa.Score > 0 and aa.Score < oa.Score then q.Id end)
from Posts q
inner join Posts aa
  on q.AcceptedAnswerId = aa.Id
inner join Posts oa
  on q.Id = oa.ParentId
  and q.AcceptedAnswerId <> oa.Id
where q.PostTypeId = 1
  and q.OwnerUserId <> aa.OwnerUserId -- exclude self-accepts

Enter Parameters

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