我正在尝试以下。我的内部查询工作正常。但是当我尝试整个查询时出现错误。请提供您的意见。
select 
   x.TeamProjectProjectNodeName,
   x.TestPlanName, 
   (case when x.ResultOutcome in ('Aborted','Error','Failed','Inconclusive','Timeout','Blocked') 
     then sum(count(x.ResultOutcome)) else 0
     as "Failed"  
     when x.ResultOutcome in ('Passed') 
     then sum(count(x.ResultOutcome)) else 0
     as "Passed" 
     when x.ResultOutcome in ('Not Executed') 
     then sum(count(x.ResultOutcome)) else 0
     as "Not Run"
     END
    )
from (select 
         TeamProjectProjectNodeName,
         TestPlanName,
         ResultOutcome, 
         count(*) as Total 
      from [Tfs_Warehouse].[dbo].[TestResultView] 
      where TestPlanName IS NOT NULL
      GROUP BY TeamProjectProjectNodeName, TestPlanName, ResultOutcome
     ) x
order by TeamProjectProjectNodeName asc, TestPlanName asc 
这就是我从内部查询中得到的 -
TeamProjectProjectNodeName  TestPlanName    ResultOutcome   Total
ACATS                       Test Automation Aborted            26
ACATS                       Test Automation Failed             61
这是我正在寻找的最终结果格式 -
TeamProjectProjectNodeName  TestPlanName    Failed  Passed    Not_Run
ACATS                       Test Automation 87     0        0