如标题所述,我们希望获得原始提问者接受他们自己的答案作为最佳答案的所有帖子(包括用户、评论和建议的编辑)。换句话说,所有情况下OwnerUserId for PostTypeId 1 = OwnerUserId for PostTypeId 2
。
SEDE DB
我正在为此苦苦挣扎,因为我对架构没有深入的了解。
这是来自SEDE
获得具有高自我接受率(并且具有> 10个答案)的用户的示例,但我们需要具有自我接受答案的帖子,而不仅仅是用户。
SELECT TOP 100
Users.Id AS [User Link],
(
CAST(COUNT(a.Id) AS float) /
CAST(
(
SELECT COUNT(*)
FROM Posts p
WHERE p.OwnerUserId = Users.Id
AND PostTypeId = 1
)
AS float
) * 100
) AS SelfAnswerPercentage
FROM Posts q
INNER JOIN Posts a ON q.AcceptedAnswerId = a.Id
INNER JOIN Users ON Users.Id = q.OwnerUserId
WHERE q.OwnerUserId = a.OwnerUserId
GROUP BY Users.Id, DisplayName
HAVING COUNT(a.Id) > 10
ORDER BY SelfAnswerPercentage DESC