0

如果大于 0,我正在尝试根据案例数返回结果,但是当我尝试执行存储过程时,我收到一条错误消息:操作数类型冲突:uniqueidentifier 与 tinyint 不兼容。这适用于我在 where 子句中的嵌套 select 语句。

SELECT 
      O.OfficeId,
      O.OfficeName AS Name,
      AT.Description AS CaseActivity,
      SUM(A.Duration) AS [CaseMinutes], 
      CAST(SUM(A.Duration) AS FLOAT) / 60 AS [CaseHours],  
      COUNT(A.ActivityId) AS Activities,
      COUNT(DISTINCT A.CaseId) AS Cases,
      MIN(CAST(A.Duration AS FLOAT) / 60) AS [Case Min Time],
      MAX(CAST(A.Duration AS FLOAT) / 60) AS [Case Max Time],
      SUM(CAST(A.Duration AS FLOAT) / 60) / COUNT(A.ActivityId) AS [Case Avg Time],
      SUM(CAST(A.Duration AS FLOAT) / 60) AS [Case TotalHours]
  FROM Activity A
      INNER JOIN ActivityType AT ON A.ActivityTypeId = AT.ActivityTypeId
      INNER JOIN ActivityEntry AE ON A.ActivityEntryId = AE.ActivityEntryId
      INNER JOIN [Case] C ON A.CaseId = C.CaseId
      INNER JOIN [Office] O ON AE.OfficeId = O.OfficeId
      INNER JOIN [User] U ON C.CreatedByUserId = U.UserId
  WHERE  A.CaseId in(select A.CaseId from Activity where A.CaseId > 1 AND .dbo.DateOnly(AE.ActivityDate) BETWEEN @BeginDate AND @EndDate)
  GROUP BY 
        O.OfficeId,
        O.OfficeName,
        AT.Description

**来自存储过程的期望目标* *
我想从这个存储过程返回结果,其中案例计数大于 0。目前,此存储过程返回案例 0 或更大的所有活动。我只对获取案例大于 0 的活动感兴趣。在我的 where 子句中,我试图插入另一个 select 语句,它将结果过滤到案例 > 0。

4

1 回答 1

0

错误信息告诉你

其中一项比较是比较两列不同类型的内容。

查看表结构并查看您正在比较的哪些列具有唯一标识符,哪些具有整数,然后查看 sql 并查看您正在比较哪些列。

于 2012-06-04T13:32:32.390 回答