MySQL and Json tags by Month

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 DATEPART(year, p.CreationDate) AS Year, DATEPART(month, p.CreationDate) AS Month, 
  COUNT(*) AS count_mysql, 
  COUNT(tj.Id) AS count_json
FROM Posts AS p
INNER JOIN PostTags AS pm ON p.Id=pm.PostId
INNER JOIN Tags AS tm ON pm.TagId=tm.Id AND tm.TagName='mysql'
LEFT OUTER JOIN PostTags AS pj ON p.Id=pj.PostId
LEFT OUTER JOIN Tags AS tj ON pj.TagId=tj.Id AND tj.TagName='json'
WHERE p.PostTypeId=1
GROUP BY DATEPART(year, p.CreationDate), DATEPART(month, p.CreationDate)
ORDER BY Year, Month

Enter Parameters

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