Possible tag synonyms

1

Please login or register to vote for this query.

(click on this box to dismiss)

Shows tag synonyms you may suggest.

Stack Apps

Q&A for apps, scripts, and development with the Stack Exchange API

DECLARE @UserId INT;

SELECT @UserId = Id FROM Users WHERE AccountId = ##SEAccountId:INT##;

WITH Raw AS (
  SELECT PostTags.TagId, SUM(5 - 2 * Votes.VoteTypeId) AS Score
  FROM Posts, Votes, PostTags
  WHERE
    Votes.PostId = Posts.Id
    AND
    Posts.CommunityOwnedDate IS NULL
    AND
    Posts.PostTypeId = 2
    AND
    Votes.VoteTypeId BETWEEN 2 AND 3
    AND
    Posts.OwnerUserId = @UserId
    AND
    PostTags.PostId = Posts.ParentId
  GROUP BY PostTags.TagId
  HAVING SUM(5 - 2 * Votes.VoteTypeId) >= 5
),
Intersects AS (
  SELECT A.TagId AS TagIdA, B.TagId AS TagIdB, COUNT(*) AS Count
  FROM PostTags A, PostTags B
  WHERE
    A.PostId = B.PostId
    AND
    A.TagId <> B.TagId
    AND
    A.TagId IN (SELECT TagId FROM Raw)
  GROUP BY A.TagId, B.TagId
)
SELECT
  TagsA.TagName,
  TagsB.TagName,
  TagsA.Count + TagsB.Count - 2 * Intersects.Count AS Diff
FROM Intersects, Tags TagsA, Tags TagsB
WHERE
  Intersects.TagIdA = TagsA.Id
  AND
  Intersects.TagIdB = TagsB.Id
ORDER BY Diff, TagsA.Id, TagsB.Id

Enter Parameters

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