postgresql-count

0

Please login or register to vote for this query.

(click on this box to dismiss)

Game Development Meta

Q&A about the site for professional and independent game developers

SELECT 
    DATEPART(YEAR, p.CreationDate) AS Year,
    DATEPART(MONTH, p.CreationDate) AS Month,
    t.TagName,
    SUM(p.ViewCount) AS TotalViews
FROM 
    Posts p
JOIN 
    PostTags pt ON p.Id = pt.PostId
JOIN 
    Tags t ON pt.TagId = t.Id
WHERE 
    t.TagName IN ('postgresql', 'sql-server')
GROUP BY 
    DATEPART(YEAR, p.CreationDate),
    DATEPART(MONTH, p.CreationDate),
    t.TagName
ORDER BY 
    Year,
    Month,
    t.TagName;

Enter Parameters

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