我需要创建一个sql查询来分析atendimetos员工
我的目标是使用此查询并创建一个显示总分钟数的图表:有多少人在120分钟(非常服务时间)和 有多少人在C#
的图表中使用了120分钟以下(普通电话)最简单的方法是在我做对的时候产生两列?
我该怎么做?我无法想到解决方案。
SELECT SUM(CallDuration)
FROM CallsFromCustomers
WHERE DATE(CallDate) Between'2015-06-01' And '2015-06-31'
AND CallDuration < 120
UNION
SELECT
SUM(CallDuration)
FROM CallsFromCustomers
WHERE DATE(CallDate) Between '2015-06-01' And '2015-06-31'
AND CallDuration >= 120
结果
SUM(CallDuration)|
5584 |
759 |
答案 0 :(得分:1)
SELECT
(SELECT COUNT(*)
FROM CallsFromCustomers
WHERE DATE(CallDate) Between'2015-06-01' And '2015-06-31'
AND CallDuration < 120) AS ShortCalls,
(SELECT COUNT(*)
FROM CallsFromCustomers
WHERE DATE(CallDate) Between '2015-06-01' And '2015-06-31'
AND CallDuration >= 120) AS LongCalls