Average Score of All Questions in [Tag]

1

Please login or register to vote for this query.

(click on this box to dismiss)

Gets the average score of a question tagged with [tag] (Sums score of all questions tagged with [tag], then divides by total quantity of such questions).

Android Enthusiasts

Q&A for enthusiasts and power users of the Android operating system

DECLARE @TagId int = (  -- Get TagId of [tag] for use in SELECT
SELECT
  t.Id
FROM Tags t
WHERE t.TagName = ##TagName:string##
)

SELECT
  ##TagName:string## AS [TagName],
  SUM(pwd.Score) * 1.0 / COUNT(pwd.Score) AS [Avg. Question Score .],
  COUNT(pwd.Score) AS [Total Questions]
FROM PostTags pt
JOIN PostsWithDeleted pwd ON pwd.Id = pt.PostId
WHERE pt.TagId = @TagId


-- TagName: Exact Name of Tag:

Enter Parameters

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