;with TopQuestionAnswers as ( select top 15 p.Id as Quest...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Sitecore Meta

Q&A about the site for developers and end users of the Sitecore CMS and multichannel marketing software

;with TopQuestionAnswers
as
(
    select top 15 
        p.Id as QuestionId
        , (select count(*) from Votes as v where v.PostId = p.Id and v.VoteTypeId = 2) as UpVotes        
        , p.Title as Question
        , pp.Body as Answer
    from Posts as p
        inner join Posts as pp
            on p.Id = pp.ParentId
    where p.PostTypeId = 1
        and pp.PostTypeId = 2
        and p.AcceptedAnswerId = pp.Id
    order by UpVotes desc
)
select
    qa.*
    ,
    (select string_agg(t.TagName, ',') 
        from PostTags as pt
            inner join Tags as t
                on pt.TagId = t.Id
        where pt.PostId = qa.QuestionId) as Tags
from TopQuestionAnswers as qa
order by qa.UpVotes desc

Enter Parameters

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