Total View Count of User's Accepted Answers

0

Please login or register to vote for this query.

(click on this box to dismiss)

Gardening and Landscaping

Q&A for gardeners and landscapers

SELECT 'Grand Total' AS Title, SUM(Question.ViewCount) AS ViewCount, SUM(Answer.Score) AS Score

FROM Posts AS Answer
  INNER JOIN PostTypes ON PostTypes.Id = Answer.PostTypeId
  INNER JOIN Posts AS Question ON Question.Id = Answer.ParentId

WHERE
  PostTypes.Name = 'Answer' AND
  Answer.OwnerUserId = ##UserId## AND
  Answer.CommunityOwnedDate IS NULL AND
  Answer.CreationDate >= 2023-04-01

UNION ALL

SELECT
  Question.Title, Question.ViewCount, Question.Score

FROM Posts AS Answer
  INNER JOIN PostTypes ON PostTypes.Id = Answer.PostTypeId
  INNER JOIN Posts AS Question ON Question.Id = Answer.ParentId

WHERE
  PostTypes.Name = 'Answer' AND
  Answer.OwnerUserId = ##UserId## AND
  Answer.CommunityOwnedDate IS NULL AND
  Answer.CreationDate >= 2023-04-01
  
ORDER BY
  ViewCount DESC

Enter Parameters

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