Linkyness Leaderboard (including external links)

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 @LinkPattern VARCHAR(100) = 'a href="';

SELECT
  RANK() OVER(ORDER BY AVG(
    CAST((len(A.Body) - len(replace(A.Body, @LinkPattern, ''))) AS float)
      /CAST(len(@LinkPattern) AS float)
  ) DESC) AS Ranking,
  AVG(
    CAST((len(A.Body) - len(replace(A.Body, @LinkPattern, ''))) AS float)
      /CAST(len(@LinkPattern) AS float)
  ) AS [Link Average],
  U.Id AS [User Link]
FROM Posts A
  INNER JOIN Users U
    ON A.OwnerUserId = U.Id
WHERE A.PostTypeId = 2
GROUP BY U.Id
ORDER BY AVG(
    CAST((len(A.Body) - len(replace(A.Body, @LinkPattern, ''))) AS float)
      /CAST(len(@LinkPattern) AS float)
  ) DESC

Enter Parameters

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