如何在此查询中添加总列?
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
目前我正在收回我想要的结果,但我希望在最右边包含所有已完成或打开的记录的总列。
答案 0 :(得分:2)
添加
, [Completed] + [Open] AS Total
到SELECT
列表