Self-answered questions

1

Please login or register to vote for this query.

(click on this box to dismiss)

View vote counts on self-answered questions.

Moderators

Q&A for community managers, administrators, and moderators

-- MaxTime: Max time difference in minutes
declare @max_time int = ##MaxTime:int?5##

select q.Id as [Post Link],
    --q.Score as [Q score],
    count(qu.Id) as [Q up],
    count(qd.Id) as [Q down],
    --a.Score as [A score],
    count(au.Id) as [A up],
    count(ad.Id) as [A down]
from Posts q
inner join Posts a on a.PostTypeId = 2
    and q.OwnerUserId = a.OwnerUserId
    and a.ParentId = q.Id
    and datediff(minute, q.CreationDate, a.CreationDate) < @max_time
inner join Votes qu on qu.VoteTypeId = 2 and qu.PostId = q.Id
inner join Votes qd on qd.VoteTypeId = 3 and qd.PostId = q.Id
inner join Votes au on au.VoteTypeId = 2 and au.PostId = a.Id
inner join Votes ad on ad.VoteTypeId = 3 and ad.PostId = a.Id
group by q.Id, a.Id--q.Score, a.Id, a.Score
order by q.Id

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results