SELECT users.location, DATEADD(mm, (Year(Posts.CreationDa...

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

SELECT users.location,
  DATEADD(mm, (Year(Posts.CreationDate) - 1900) * 12 + Month(Posts.CreationDate) - 1, 0) AS Month,
  Tags.TagName,
  COUNT(*) AS Questions

FROM Tags
  LEFT JOIN PostTags ON PostTags.TagId = Tags.Id
  LEFT JOIN Posts ON Posts.Id = PostTags.PostId
  LEFT JOIN PostTypes ON PostTypes.Id = Posts.PostTypeId
  INNER Join users on posts.owneruserid = users.id 

WHERE
  users.location != '' and
  PostTypes.Name = 'Question' AND
  Posts.CreationDate >= '2014-01-01' AND
  -- Exclude the current month
  Posts.CreationDate <= '2014-01-31' 

GROUP BY
  users.location, Year(Posts.CreationDate), Month(Posts.CreationDate), Tags.TagName

ORDER BY
  users.location, Questions DESC, Year(Posts.CreationDate), Month(Posts.CreationDate), Tags.TagName

Enter Parameters

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