我有以下查询错误输出操作数类型冲突:时间与浮动
不兼容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为时间
请帮忙
答案 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