Tags used in 90% of the questions

0

Please login or register to vote for this query.

(click on this box to dismiss)

CiviCRM

Q&A for administrators and users of the CiviCRM Constituent Relationship Management software

SELECT 
    COUNT(*) NumberOfTagsUsed
FROM (
    SELECT 
        Tags.TagName,
        COUNT(PostTags.PostId) NumQuestions,
        SUM(COUNT(PostTags.PostId)) OVER (ORDER BY COUNT(PostTags.PostId) DESC) CumulativeCount,
        SUM(COUNT(PostTags.PostId)) OVER () TotalCount
    FROM 
        Tags
        INNER JOIN PostTags ON Tags.Id = PostTags.TagId
        INNER JOIN Posts ON Posts.Id = PostTags.PostId
    WHERE 
        Posts.PostTypeId = 1 -- Only consider questions
    GROUP BY 
        Tags.TagName
) TagUsage
WHERE 
    CumulativeCount <= 0.90 * TotalCount;

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results