gpt4 book ai didi

MySQL 查询中的查询

转载 作者:行者123 更新时间:2023-11-30 00:42:43 24 4
gpt4 key购买 nike

我有以下查询,它可以很好地查询 asterisk cdr 中所有错过的队列调用,但它是重复的。也就是说,如果队列调用中有两个分机,则将其分类为两个未接来电。

查询:

SELECT count( * ) as today_total_8
FROM cdr
WHERE channel LIKE '%from-queue%'
AND disposition='NO ANSWER'
AND DATE(`calldate`) = DATE(CURDATE())

对于所有两个结果,calldate 列的值相同;如何将其添加到上述查询中以显示未接来电的计数?

SELECT 返回的数据不带计数:

calldate            channel                 disposition     
------------------------------------------------------------------------
2014-02-08 01:15:02 Local/201@from-queue-00000012;2 NO ANSWER
2014-02-08 01:15:02 Local/200@from-queue-00000013;2 NO ANSWER
2014-02-08 00:18:04 Local/201@from-queue-00000010;2 NO ANSWER
2014-02-08 00:18:04 Local/200@from-queue-00000011;2 NO ANSWER

我怎样才能做到这一点,因为我希望我的计数为 2?

最佳答案

SELECT count(distinct calldate ) as today_total_8
FROM cdr
WHERE channel LIKE '%from-queue%'
AND disposition='NO ANSWER'
AND DATE(`calldate`) = DATE(CURDATE())
GROUP BY calldate

关于MySQL 查询中的查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21640196/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com