Top 10 users comments on competing answers

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

With top10users as
(SELECT top 10 ID, displayname 
FROM users u
ORDER BY reputation desc),
 answers as (
SELECT 
   p.Id,
   p.id [Post Link],
   p.postTypeId,
   p.ParentId ,
   p.OwnerUserID,
   u.displayName
FROM Posts p
inner join  top10Users u
on p.OwnerUserID = u.id
WHERE p.postTypeID = 2


)
SELECT a.displayname, a.id [Post Link], c.text
FROM answers a
INNER JOIN posts q
ON a.ParentId = q.id
INNER JOIN posts otherAnswer
ON  q.id = otherAnswer.ParentID
and a.id <> otherAnswer.ID
INNER JOIN comments c
on otherAnswer.id = c.postid
and c.userid = a.owneruserid

Enter Parameters

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