SELECT DATEPART(YEAR, Posts.CreationDate) as Year, DATEPA...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Ask Ubuntu Meta

Q&A about the site for Ubuntu users and developers

SELECT 
    DATEPART(YEAR, Posts.CreationDate) as Year,
    DATEPART(MONTH, Posts.CreationDate) as Month,
    COUNT(*) as IssueCount,
    AVG(CAST(Posts.Score as FLOAT)) as AvgScore,
    SUM(Posts.ViewCount) as TotalViews
FROM Posts
LEFT JOIN PostTags ON Posts.Id = PostTags.PostId
LEFT JOIN Tags ON PostTags.TagId = Tags.Id
WHERE Tags.TagName IN ('safety', 'scams', 'fraud', 'payments', 'security')
    AND Posts.PostTypeId = 1
GROUP BY DATEPART(YEAR, Posts.CreationDate), DATEPART(MONTH, Posts.CreationDate)
ORDER BY Year DESC, Month DESC;

Enter Parameters

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