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",

max(a.Body)          AS "Accepted Answer",
max(a.Score)         AS "Score 1",
max(b.Body)          AS "Answer 2",
max(b.Score)         AS "Score 2",
max(c.Body)         AS "Answer 2",
max(c.Score)         AS "Score 3"




FROM Posts p
left outer JOIN Posts a ON p.AcceptedAnswerId = a.Id -- OR p.ID = a.ParentId
left outer 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 c.Id != b.Id and b.Score > c.Score 

    --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 = p.id


WHERE 
t.tagname in ('perl')  -- tag;

AND p.PostTypeId = 1   -- select questions



GROUP BY p.Id, p.ViewCount


ORDER BY p.ViewCount DESC

Enter Parameters

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