Can you subtotal rows and/or columns in a pivot table?
I have a set of queries that outputs a pivot table. Is it possible to obtain row and/or column subtotals for a pivot table ? My table I am selecting from looks like this Site FormID Present Site 1 Form A Yes Site 1 Form B Yes Site 1 Form D Yes etc... My pivot table query is this SELECT * FROM (SELECT Site, COUNT(FormID) AS NumberOfForms,FormID FROM @CRFCount WHERE Present='Yes' GROUP BY Site, FormID) d PIVOT (SUM(NumberOfForms) FOR [Site] IN ([Site 1], [Site 2], [Site 3]) ) AS p; But I really want it to result in this (which of course it does not total for me) FormID Site 1 Site 2 Site 3 Total