view count for user answers

0

Please login or register to vote for this query.

(click on this box to dismiss)

Is there any way to extract the total number of views a set of questions has received, where that set is defined as those that a user has either contributed an answer or the question? http://meta.stackexchange.com/questions/133456/how-to-obtain-total-number-of-views-for-a-user-combining-questions-and-answers

The Workplace Meta

Q&A about the site for members of the workforce navigating the professional setting

DECLARE @userID int
SET @userID = rtrim(##UserID:int##)
DECLARE @tagName varchar(255) 
SET @tagname = rtrim(##TagName:string##)


select u.id as [User Link]
, sum(q.ViewCount) as [Total Views]
from Posts a
INNER JOIN Posts q
   ON a.parentId = q.id
inner join users u on u.id = a.owneruserid
inner join PostTags pt on q.id = pt.PostId
INNER JOIN Tags T
   ON pt.TagId = t.id
where a.owneruserid = @userID
and t.TagName = @TagName
group by u.id
order by [Total Views] desc

Enter Parameters

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