SELECT TOP 10 TagName, AVG(Users.Age) AS AvgAge FROM Us...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

-- Users, Posts, PostTags, Tags
-- What is the average age of prople posting questions with a given tag?
-- e.g.:
-- --------------------
-- | TagName | AvgAge |
-- --------------------
-- | sql     |  27.5  |
-- | html    |  23.1  |
-- |    ...  |  ...   |


SELECT TOP 10
  TagName,
  AVG(Users.Age) AS AvgAge
FROM
  Users
INNER JOIN
  Posts ON Posts.OwnerUserId = Users.Id
INNER JOIN
  PostTags ON Posts.Id = PostTags.PostId
INNER JOIN
  Tags ON Tags.Id = PostTags.TagId
WHERE
  Age IS NOT NULL
GROUP BY
  TagName
ORDER BY
  AvgAge DESC

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results