操作数类型冲突:时间与浮动计算不兼容

时间:2015-06-29 06:11:10

标签: sql tsql

我有以下查询错误输出操作数类型冲突:时间与浮动

不兼容
select (sum(ReceivedContacts) * CONVERT(TIME, DATEADD(s, SUM(( DATEPART(hh, AverageWaitTime) * 3600 ) + ( DATEPART(mi, AverageWaitTime) * 60 ) + DATEPART(ss, AverageWaitTime)), 0)) / Sum(ReceivedContacts)) AS total_time
from TelephonyStats

已接收联系人的数据类型为float,AverageWaitTime为时间

请帮忙

1 个答案:

答案 0 :(得分:0)

CONVERT移至TIME并整理其余括号,它应该可以正常工作。请尝试以下查询:

SELECT 
        SUM(ReceivedContacts) * ( 
           SUM ( 
                  ( DATEPART(hh, AverageWaitTime) * 3600 ) + 
                  ( DATEPART(mi, AverageWaitTime) * 60 ) + 
                  ( DATEPART(ss, AverageWaitTime) )
               ) / SUM(ReceivedContacts)
        ) AS total_time
FROM TelephonyStats