Tutorial : Try to get 3 answsers

0

Please login or register to vote for this query.

(click on this box to dismiss)

The Workplace Meta

Q&A about the site for members of the workforce navigating the professional setting

SELECT TOP 10
p.Id            AS [Post Link],
min(p.Title)         AS "Title",
min(p.ViewCount)     AS "ViewCount",
min(p.Body)          AS "Question",
min(a.Body)          AS "Accepted Answer",
min(b.Body)          AS "Answer 2",
min(c.Body)          AS "Answer 3"



FROM Posts p
left outer JOIN Posts a ON p.AcceptedAnswerId = a.Id -- OR p.ID = a.ParentId
JOIN Posts b ON p.Id = b.ParentId

    -- AND (a.Id is not null) * a.Score / 2 < b.Score 
    --AND b.Id != a.Id
    --where a is null 
    --AND(
    --  a.Id = null
    -- OR(b.Id != a.Id  AND b.Score > a.Score / 2)
    --)

left outer JOIN Posts c ON p.Id = c.ParentId

    --AND(
    --  a = null
    --  OR(c.Id != a.Id AND c.Id != b.Id AND c.Score > a.Score / 2)
    --)


inner join posttags pt on pt.postid = p.id
inner join tags t on pt.tagid = t.id

WHERE 
t.tagname in ('perl')  -- tag
AND p.PostTypeId = 1   -- select questions
AND b.Id != c.Id
AND a.Id is null

GROUP BY p.Id, p.ViewCount

ORDER BY p.ViewCount DESC

Enter Parameters

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