SELECT Tags.Tagname AS Tag, Count(*) AS Questions, Sum(Ca...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Drupal Answers

Q&A for Drupal developers and administrators

SELECT 
    Tags.Tagname AS Tag, 
    Count(*) AS Questions, 
    Sum(Cast(Posts.ViewCount as bigint)) AS Views,
    Sum(Posts.Score) AS Score,
    Sum(Posts.FavoriteCount) AS Favorites,
    Sum(Posts.CommentCount) AS Comments,
    Sum(Posts.AnswerCount) AS Answers,
    
    
    Sum(Cast(Posts.ViewCount as bigint)) / Count(*) AS AvgViews,
    str(Sum(Posts.Score) / Cast(Count(*) AS Float),6,2) AS AvgScore,
     str(Sum(Posts.FavoriteCount) / Cast(Count(*) AS Float),6,2) AS AvgFavorite,
    str(Sum(Posts.CommentCount) / Cast(Count(*) AS Float),6,2) AS AvgComment,
    str(Sum(Posts.AnswerCount) / Cast(Count(*) AS Float),6,2) AS AvgAnswers
  FROM Posts 
  JOIN PostTags ON Posts.Id = PostTags.PostId
  JOIN Tags ON PostTags.TagId = Tags.Id
  WHERE Posts.PostTypeId = 1 
  and year(Posts.CreationDate) =2020
  GROUP BY Tags.Tagname
  ORDER BY Views DESC

Enter Parameters

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