Which MATLAB users have the most answers containing a certain function

3

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

-- Users with highest number of answers containing some function name (or other text)
-- Does not count self-answers. 
-- Shows users with at least @MinAnswers answers.

-- DECLARE @MinAnswers int = ##MinimumAnswersToMatlabTag##

SELECT TOP 100
  u.Id AS [User Link],
  sum(case when a.Body LIKE '%##FunctionName##%' then 1 else 0 end) AS TotalFunctionAnswers,
  (sum(case when a.Body LIKE '%##FunctionName##%' then 1 else 0 end)*100.0/count(*)) AS PercentageOfAnswersUsingFunction,
   count(*) AS NumAnswersToMatlabTag
FROM Posts a
INNER JOIN Users u ON u.Id = a.OwnerUserId
INNER JOIN Posts q ON a.ParentId = q.Id
INNER JOIN PostTags ON PostTags.PostId = q.Id
INNER JOIN Tags ON PostTags.TagId = Tags.Id
WHERE 
  (q.OwnerUserId <> u.Id OR q.OwnerUserId IS NULL)   --no self answers
  AND (Tags.TagName = 'matlab')
GROUP BY u.Id
--HAVING count(*) >= @MinAnswers
ORDER BY TotalFunctionAnswers DESC, NumAnswersToMatlabTag DESC
--ORDER BY PercentageOfAnswersUsingFunction DESC

Enter Parameters

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