Co-occurrences of Tags

1

Please login or register to vote for this query.

(click on this box to dismiss)

Software Quality Assurance and Testing Meta

Q&A about the site for software quality control experts, automation engineers, and software testers

DECLARE @queryTag nvarchar(35) = ##TagName:string?kubernetes##;
DECLARE @queryTagId int = (SELECT Id FROM Tags WHERE Tags.TagName = @queryTag);
DECLARE @queryTagCount decimal = (SELECT Count as queryTagCount FROM Tags WHERE Tags.Id = @queryTagId);


SELECT
    X.tag_id,
    X.Cooccurrence,
    XT.Count,
    (X.Cooccurrence * 100 /XT.Count) AS Percentage,
    (CAST(X.Cooccurrence AS decimal) / CAST(XT.Count As decimal)) As Ratio,
    LOG(@queryTagCount / Cast(XT.Count AS decimal)) AS MagnitudeSimilarity,
    (ABS(0 - LOG(@queryTagCount / Cast(XT.Count AS decimal))) + 1) /
    (CAST(X.Cooccurrence AS decimal) / CAST(XT.Count As decimal))
    AS Diff,
    TagName
FROM
    (SELECT 
        PostTags.TagId AS tag_id, COUNT(PostTags.TagId) AS Cooccurrence
    FROM
        PostTags
    WHERE
        PostTags.PostId IN (SELECT 
                PostTags.PostId
            FROM
                PostTags
            WHERE
                PostTags.TagId = @queryTagId)
            AND PostTags.TagId != @queryTagId
    GROUP BY PostTags.TagId) AS X
        INNER JOIN 
        Tags As XT ON XT.Id = X.tag_id
        
ORDER BY Diff

Enter Parameters

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