Hoody
Hoody

Reputation: 3381

Add total column to cross tab pivot query

How do I add a total column to this query?

SELECT YearOfAccount, [Completed] AS Closed, [Open] AS Opened
FROM 
(SELECT YearOfAccount, Status, CaseCode
FROM Records ) myRecords 
PIVOT
(
COUNT(CaseCode)
FOR [Status] IN
( [Completed], [Open])
) AS pvt

Currently I am getting back the results I want but I want to include a total column on the far right for all records that are completed or Open.

Upvotes: 0

Views: 1691

Answers (1)

Martin Smith
Martin Smith

Reputation: 453667

Add

, [Completed] + [Open] AS Total

to the SELECT list

Upvotes: 2

Related Questions