SQL语句应该返回更多行

时间:2015-03-12 08:10:05

标签: sql-server stored-procedures

我的sql语句是一个存储过程,它应该返回由每个代理分组的总分数(rawCSATAgentName) 这是我的程序:

ALTER PROCEDURE [dbo].[getCSATTeam]
@OtherDate DATE,
@DateToday DATE,
@FullNames nvarchar(MAX)
AS
BEGIN
SET NOCOUNT ON;


  SELECT [rawCSATAgentName],

    ( CAST((SUM(case [rawCSATFCR] when 1 then 1 end) + 
    SUM(case [rawCSATFCR] when 0 then 0 when 2 then 0 end)) AS FLOAT)
    /
    (COUNT([rawCSATFCR])) * 100 ) AS [FCR],


   ( CAST((SUM(CASE WHEN [rawCSATHelpfulness] IN (6,7) THEN 1 END) + 
   SUM(CASE WHEN [rawCSATHelpfulness] IN (0,1,2,3,4,5) THEN 0 END)) AS FLOAT)
   /
   (COUNT([rawCSATHelpfulness])) * 100 )
    AS [Helpfulness],


   ( CAST((SUM(CASE WHEN [rawCSATSAK] IN (6,7) THEN 1 END) + 
   SUM(CASE WHEN [rawCSATSAK] IN (0,1,2,3,4,5) THEN 0 END)) AS FLOAT)
   /
   (COUNT([rawCSATSAK])) * 100 )
    AS [SkillsAndKnowledge],


   ( CAST((SUM(CASE WHEN [rawCSATOSR] IN (6,7) THEN 1 END) + 
   SUM(CASE WHEN [rawCSATOSR] IN (0,1,2,3,4,5) THEN 0 END)) AS FLOAT)
   /
   (COUNT([rawCSATOSR])) * 100 )
    AS [OverallSatisfaction]


   FROM [CSATScoresRaw]

   WHERE (convert(varchar(10),[rawCSATDateTime],101) BETWEEN @OtherDate AND @DateToday)
     AND [rawCSATAgentName] IN (SELECT i.str FROM dbo.iter$simple_strlist_to_tbl(@FullNames) AS i)

  GROUP BY [rawCSATAgentName]

  ORDER BY [rawCSATAgentName]

  END

但它只返回一个[rawCSATAgentName]的总得分。为什么呢?

0 个答案:

没有答案