I have a query on pivot tables - I've searched t'internet and can't find anything that really answers my question.Table: "Calls" with columnsID, Cat [a,b or c], Status [1,2,3 or 4]
Pivot table queryselect Cat, [1] as 'start', [2] as 'working', [3] as 'closed', [4] as 'error'from ( select Cat, Status from calls ) cPIVOT ( Count(status) for Status in ([1],[2],[3],[4]) ) p
which returnsCat start working closed error---- ----------- ----------- ----------- -----------a 3 3 1 1b 1 4 4 2c 1 1 0 1
This is all as I'd expect - however, I'd like to add a "total" column to the right of each row, and then also a total row to the bottom of the table, to get the result as follows:Cat start working closed error total---- ----------- ----------- ----------- ----------- -----------a 3 3 1 11 18b 1 4 4 2 11c 1 1 0 1 3tot 5 8 5 14 23
Is this possible? If so, can someone help me out?