User Answer Accepted Rate (per tag)

0

Please login or register to vote for this query.

(click on this box to dismiss)

Gives the percentage of accepted answers for a user, per tag.

Economics

Q&A for those who study, teach, research and apply economics and econometrics

DECLARE @UserId int = ##UserId##

SELECT
  t.TagName,
  count(*) AS NumAnswers,
  sum(case when q.AcceptedAnswerId = a.Id then 1 else 0 end) AS NumAccepted,
  (sum(case when q.AcceptedAnswerId = a.Id then 1 else 0 end)*100.0/count(*)) AS AcceptedPercent
FROM Posts a
INNER JOIN Users u ON u.Id = a.OwnerUserId
INNER JOIN Posts q ON a.ParentId = q.Id
INNER JOIN PostTags pt ON pt.PostId = q.Id
INNER JOIN Tags t ON t.Id = pt.TagId
WHERE 
  (q.OwnerUserId <> u.Id OR q.OwnerUserId IS NULL)   --no self answers
  and u.id = @UserId
GROUP BY t.TagName
ORDER BY NumAnswers DESC, AcceptedPercent DESC

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results