All my answers sort score , viewcount, creationDate

0

Please login or register to vote for this query.

(click on this box to dismiss)

All my answers on the site

Sitecore Meta

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

-- All my answers
-- All my answers on the site

DECLARE @UserId int = ##UserId##
Select * from 
(SELECT 
    q.id aid,
    a.Id AS [Post Link],
    CASE WHEN q.AcceptedAnswerId=a.Id THEN 'Accepted' END AS Accepted,
    a.Score
FROM
    Posts q
  INNER JOIN
    Posts a ON q.Id = a.ParentId
WHERE
    a.OwnerUserId = @UserId
  AND
    a.PostTypeId = 2
)  AA 
Inner join 
(SELECT DISTINCT Question.Id as bid, Question.CreationDate AS [Date], Question.ViewCount 
FROM Posts as Answers, Posts as Question 
WHERE Answers.PostTypeId = 2 
AND Answers.OwnerUserId = @UserId 
AND Question.Id = Answers.ParentId
) BB on AA.aid = BB.bid
ORDER BY  Score ASC , ViewCount DESC , DATE ASC;

Enter Parameters

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