How many posts per month for a tag?

0

Please login or register to vote for this query.

(click on this box to dismiss)

Shows the trend for your favourite tag

Software Quality Assurance and Testing Meta

Q&A about the site for software quality control experts, automation engineers, and software testers

-- How many posts per month for a tag?
-- Shows the trend for your favourite tag

DECLARE @TagName varchar(255) = '##TagName##'

SELECT r.PYear, r.PMonth,
       (SELECT COUNT(*)
        FROM Posts
        WHERE Posts.Tags
        LIKE '%<##TagName##>%'
        AND DATEADD(month,
                    DATEPART(month,
                             Posts.CreationDate),
                    DATEADD(year,
                            DATEPART(year,
                                     Posts.CreationDate),
                            0))
         <= DATEADD(month,r.PMonth,DATEADD(year,r.PYear, 0))) as Posts
FROM (
       SELECT DISTINCT YEAR(Posts.CreationDate) as PYear,
              MONTH(Posts.CreationDate) as PMonth
       FROM Posts
       WHERE Posts.Tags LIKE '%<##TagName##>%'
     ) AS r
GROUP BY r.Pyear, r.PMonth
ORDER BY r.PYear, r.PMonth

Enter Parameters

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