count(distinct cc.callednumber) as 外呼客户总数 , count( cc.callednumber) as 外呼次数 , count(distinct cc.callednumber) as 接通客户数
from Agent a , AgentGroup b , AgentGroupRelation c , (SELECT * FROM cc_calldetail UNION SELECT * FROM cc_calldetail_bak) cc
where cc.calltype between 3 and 5
and a.agentid = c.agentid and b.groupid = c.groupid and a.agentcode =cc.firstagentId
and b.groupId IN('SHNKAG0000000001','SHNKAG0000000005')
group by a.agentCode ,a.Name如上的SQL语句
查询的结果是
工号 姓名 工时 外呼客户总数 外呼次数 接通次数
1060 1005 504 2 4 2
1061 1001 252 1 2 1
1062 1006 376 2 4 2
但是发现结果有误实际应该为
1060 1005 126 2 4 2
1061 1001 63 1 2 1
1062 1006 126 2 4 2
在下想问一下这该怎么处理?
还有就是多个聚合函数时怎么控制?
谢谢
from Agent a , AgentGroup b , AgentGroupRelation c , (SELECT * FROM cc_calldetail UNION SELECT * FROM cc_calldetail_bak) cc
where cc.calltype between 3 and 5
and a.agentid = c.agentid and b.groupid = c.groupid and a.agentcode =cc.firstagentId
and b.groupId IN('SHNKAG0000000001','SHNKAG0000000005')
group by a.agentCode ,a.Name如上的SQL语句
查询的结果是
工号 姓名 工时 外呼客户总数 外呼次数 接通次数
1060 1005 504 2 4 2
1061 1001 252 1 2 1
1062 1006 376 2 4 2
但是发现结果有误实际应该为
1060 1005 126 2 4 2
1061 1001 63 1 2 1
1062 1006 126 2 4 2
在下想问一下这该怎么处理?
还有就是多个聚合函数时怎么控制?
谢谢
解决方案 »
- 发6次了,版主别再删贴,行么? 哪有错我改! --求自定义公式解决方案!
- MS SQL 行锁定问题~~~~~~~~~~~~~~~~~~~~~~~~~~~
- 关于数据库问题
- 请教:一条sql的查询语句
- 怎样消除提出来的记录里的NULL值
- 来帮我看看这句UPDATE语句
- 〓〓>==→Access报表中的数值字段,要去掉小数点后的低位0,如0.40,要显示成0.4,应该用什么格式?急,请赐教.
- 我想把7.0的数据库转为2000的,怎么办啊?
- 数据库恢复什么函数?
- 不用重启数据库,怎样解决SQL server里某个表被锁住了的问题?
- 服务器: 消息 156,级别 15,状态 1,行 16
- 2条记录,如何交换某同一字段的内容(排序),请帮忙看看这两行代码
1061 1001 63 1 1 1
1062 1006 126 2 2 2
还有搞忘了,这个外呼次数也错了
了