0

有人可以检查我的查询,它似乎没有执行。我试图从 callAgent 和 CallsAbandoned = 获得放弃率百分比到 abandomnet % 98.45。“列”中的字段是一列。

公式应为:CallsAbandoned >0 或 CallsAgent >0 然后 CallsAbandoned / CallsAgent *100

CASE WHEN 'callsadandoned' > 0 OR 'callsagent' > 0 
THEN 'callsadandoned' / 'callsagent' *100 END 
AS AdnandonmentRate

SELECT  queuecall1.StartTime, 
    queuecall1.TargetDN,
    queuecall1.TargetType,
    queuecall1.QueueDN,
    queuecall1.QueueName,
    queuecall1.DurationSeconds,
    queuecall1.CallID,
    call1.CallType,
    queuecall1.Duration,
    queuecall1.ExitReason,
    datename(mm, queuecall1.StartTime) AS Month,
    datename(YYYY, queuecall1.StartTime) AS Year,
    datename(DW, queuecall1.StartTime) AS Weekday,
    datename(QQ, queuecall1.StartTime) AS Quarter,
    datename(WK, queuecall1.StartTime) AS Week,
    CASE WHEN ExitReason = 7 THEN 1 ELSE 0 END AS CallsAbandoned,
    CASE WHEN ExitReason = 1 THEN 1 ELSE 0 END AS CallsAgent,
    CASE WHEN calltype = 1 THEN 1 ELSE 0 END AS CallsInternal,
    CASE WHEN calltype = 2 THEN 1 ELSE 0 END AS CallsExternal,
    CASE 
     WHEN exitreason = 9 
          AND targettype = 3 
          AND targetdn = queuedn 
           OR exitreason IN ( 2, 3, 4, 5 ) 
              AND targettype = 3 THEN 1 ELSE 0 END AS CallsVM, 
   CASE WHEN (ExitReason = 9) AND 
    TargetDN <> QueueDN OR 
    ExitReason = 10 OR
    ExitReason = 11 THEN 1 ELSE 0 END as CallsTransfered,
    CASE WHEN CallsAbandoned > 0 OR CallsAgent > 0 THEN CallsAbandoned /           CallsAgent *100 END AS AdnandonmentRate
    FROM   (queuecall queuecall1 INNER JOIN connect connect1 
ON queuecall1.ConnectTableID=connect1.ID) INNER JOIN call call1 
ON connect1.CallTableID=call1.ID

我得到的错误是:Msg 8117,Level 16,State 1,Line 31 操作数数据类型 varchar 对于除法运算符无效。

任何协助都会很棒。

谢谢,阿伦

4

1 回答 1

0

通过在列名周围放置撇号,您将它们视为单独的 varchar(文本)值而不是列名。划分时不能使用错误正确的说法。

如果您删除这些,它将改为知道您指的是列名。假设您的列中的值是可以划分的适用类型。以下应该有效:

CASE WHEN callsadandoned > 0 OR callsagent > 0 THEN callsadandoned / callsagent *100 END AS AdnandonmentRate

于 2013-12-06T23:14:17.427 回答