Q&A about the site for software engineers working on automated testing, continuous delivery, service integration and monitoring, and building SDLC infrastructure
SELECT * FROM (SELECT T.TagName, Year(a.creationDate) yr, CASE WHEN (GROUPING(Substring(DateName(m,a.creationDate),1,3)) = 1) THEN 'All' ELSE Substring(DateName(m,a.creationDate),1,3) END mh , SUM(a.score) Total FROM Posts a INNER JOIN Posts q ON a.ParentID = q.id INNER JOIN postTags pt ON q.id = pt.PostId INNER JOIN Tags t ON Pt.TagiD = t.id WHERE a.owneruserID = ##UserID## and t.tagname in ('sql', 'sql-server') GROUP BY t.TagName, Year(a.creationDate) , Substring(DateName(m,a.creationDate),1,3) WITH ROLLUP HAVING GROUPING (Year(a.creationDate)) = 0 ) SourceTable PIVOT ( sum( Total ) FOR mh IN ([Jan],[Feb],[Mar],[Apr],[May],[Jun],[Jul],[Aug],[Sep],[Oct],[Nov],[Dec], [All]) ) AS PivotTable