Q&A for administrators and users of the CiviCRM Constituent Relationship Management software
-- Calculate the total number of posts SELECT COUNT(Id) FROM Posts WHERE PostTypeId = 1; -- Only consider questions (PostTypeId = 1) -- Calculate the total number of tags SELECT COUNT(DISTINCT PostTags.TagId) FROM PostTags INNER JOIN Posts ON PostTags.PostId = Posts.Id WHERE Posts.PostTypeId = 1; -- Only consider tags on questions -- Calculate Tag Usage SELECT Tags.TagName, COUNT(PostTags.PostId) 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;