select count(distinct q.id) from posts q left outer join ...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

select count(distinct q.id)
  from posts q
  left outer join posts a
    on q.id = a.parentid
   and a.posttypeid = 2
 where q.posttypeid = 1
   and q.closeddate is null
   and DATEPART(yyyy, q.CreationDate) = 2012
   and q.score > 0
   and not exists ( select 1
                      from posts
                     where parentid = q.id
                       and posttypeid = 2
                       and score > 1
                       )

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached