我试图查询一个表,但它似乎不起作用。有人能帮忙吗?

SELECT     ExitReason AS CallsAbandoned
FROM         queuecall
WHERE     (ExitReason = 7) THEN
                  (ExitReason = 1 ELSE
                  (ExitReason = 0)))

我想要的否认或结果是:
if {ExitReason} = 7 THEN 1 ELSE 0

我不确定如何完成正确的查询。
谢谢,
阿龙

最佳答案

以下是您要找的:

SELECT CASE WHEN ExitReason = 7
       THEN 1
       ELSE 0
       END AS CallsAbandoned
FROM queuecall

或者,如果您想要对案件的结果进行统计,请尝试以下操作:
SELECT SUM(CASE WHEN ExitReason = 7
       THEN 1
       ELSE 0
       END) AS CallsAbandoned
FROM queuecall

09-11 18:32