with TopAnswers as ( select * from Users as u cross apply (

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 TopAnswers as
(
    select *
    from Users as u
        cross apply
        (
            select top 5 p.Id as AnswerId, p.Body, ParentId as QuestionId, p.Score
            from Posts as p
            where p.PostTypeId = 2
                and p.OwnerUserId = u.Id
            order by p.Score desc
        ) as a
    where u.Id = 7742920
)
select 
    a.DisplayName as [User]
    , p.Title as Question
    , p.Body as QuestionBody
    , a.Body as Answer
    , a.Score
    , (select string_agg(c.Text, ',') from Comments as c where c.PostId = a.AnswerId) as Comments
from TopAnswers as a
    inner join Posts as p
        on a.QuestionId = p.Id

Enter Parameters

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