[英]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. 目前我正在收回我想要的结果,但我希望在最右边包含所有已完成或打开的记录的总列。
Add 加
, [Completed] + [Open] AS Total
to the SELECT
list 到SELECT
列表
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.