Demo for 11140169

0

Please login or register to vote for this query.

(click on this box to dismiss)

Genealogy and Family History Meta

Q&A about the site for expert genealogists and people interested in genealogy or family history

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
    ) SourceTable
/* PIVOT
(
sum( Total )
FOR mh IN ([Jan],[Feb],[Mar],[Apr],[May],[Jun],[Jul],[Aug],[Sep],[Oct],[Nov],[Dec], [All])
) AS PivotTable
    
*/

Enter Parameters

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