Count Answerers per Tag

0

Please login or register to vote for this query.

(click on this box to dismiss)

Joomla Meta

Q&A about the site for Joomla! administrators, users, developers and designers

DECLARE @tagName varchar(255) 
DECLARE @tagInput bit
SET @tagname = rtrim(##TagName:string##)

IF RTRIM(@tagname) = ''

   SET @tagInput = 0 
ELSE
   SET @tagInput = 1

 
SELECT COUNT(DISTINCT a.OwnerUserId),
   t.TagName
FROM 
   votes v
   INNER JOIN Posts a
   ON v.PostID = a.ID
   INNER JOIN Posts q
   ON a.parentId = q.id
   INNER JOIN PostTags pt
   ON q.id = pt.PostId
   INNER JOIN Tags T
   ON pt.TagId = t.id
WHERE
   v.voteTypeId = 2  -- Up votes
   and a.PostTypeID = 2  -- Answers only
   AND (a.CommunityOwnedDate is null or 
    a.CommunityOwnedDate > v.CreationDate)
   AND 
   (@tagInput = 0
    or t.TagName = @TagName)
    AND a.OwnerUserId is not null
GROUP BY
   t.TagName

Enter Parameters

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