How much does losing a duel cost?

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

with two_answers as (
  select min(a.Id) first, max(a.Id) last
  from Posts q
       join Posts a on q.Id = a.ParentId
  where q.AnswerCount = 2
--        and q.ViewCount <= 100
  group by q.Id
  having getdate() - max(a.CreationDate) > 30
)

select avg(cast(isnull(f.Score, 0) as float)),
                 avg(cast(isnull(l.Score, 0) as float)),
       round(avg(cast(isnull(f.Score, 0) as float) 
                 - cast(isnull(l.Score, 0) as float)), 2) FGITW
                 
from two_answers
     join Posts f on f.Id = first
     join Posts l on l.Id = last
where isnull(f.Score, 0) >= 0
      and isnull(l.Score, 0) >= 0
      and f.CreationDate < l.CreationDate
--      and datediff(minute, f.CreationDate, l.CreationDate) between 1 and 5

Enter Parameters

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