Average number of links per answer

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @UserId INT = ##UserId##;
DECLARE @LinkPattern VARCHAR(100) = 'scifi.stackexchange.com';

SELECT
  AVG(
    CAST((len(A.Body) - len(replace(A.Body, @LinkPattern, ''))) AS float)
      /CAST(len(@LinkPattern) AS float)
  ) AS [Link Average]
FROM Posts A
WHERE
  A.OwnerUserId = @UserId
  AND A.PostTypeId = 2

Enter Parameters

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