1

我有疑问,我遇到了麻烦。我正在尝试在以下 KEY 中捕获参数:

//  We track all calls ending up in Workgroup Voice Mailbox:
//  ExitReason:
//  9 - TransferVM
//  2 - ForwardAlways (Workgroup is set up to always forward calls)
//  3 - ForwardBusy
//  4 - ForwardNoAnswer
//  5 - ForwardNoAgent
//
//  TargetType:
//  3 - Mailbox
//  
//  TargetDN:
//  Target's Extension.
//  If target is workgroup's mailbox (TargetDN = QueueDN and TargetType = 3)
//  call ended up in workgroup mailbox.
//

我要执行的查询是:

Select CASE WHEN ExitReason = 9 AND 
    TargetType = 3 AND 
    TargetDN = QueueDN OR 
    ExitReason = 2 OR
    ExitReason = 3 OR
    ExitReason = 4 OR
    ExitReason = 5 AND
    TargetType = 3 THEN 1 ELSE 0 AS CallsVM
FROM   (queuecall queuecall1 INNER JOIN connect connect1 
ON queuecall1.ConnectTableID=connect1.ID) INNER JOIN call call1 
ON connect1.CallTableID=call1.ID

我收到多个 AS 和 FROM 错误。任何帮助都会很棒。谢谢,阿伦

4

1 回答 1

1

END在 case 语句中缺少关键字。你也错过了使用的机会IN

例如

SELECT 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 
FROM   queuecall queuecall1 
       INNER JOIN connect connect1 
               ON queuecall1.connecttableid = connect1.id 
       INNER JOIN call call1 
               ON connect1.calltableid = call1.id 
于 2013-12-05T21:34:23.387 回答