求SQL高手帮忙!
select a.agt_id as agt_id,
a.agt_nme as agt_name,
b.ob_task_no as ob_task_no,
c.ob_task_name as ob_task_name,
count(b.ob_call_no) as coounter1,
count(c.ob_call_no) as counter2
from t_cc_agt a,ob_queue b,ob_result c
where a.agt_id=b.allotuser_id and a.agt_id=c.usr_id
and b.allotuser_id=c.usr_id
and b.ob_task_no=c.ob_task_no
and b.ob_task_no='888'
and c.ob_task_no='888'
group by a.agt_id,a.agt_nme,b.ob_task_no,c.ob_task_name
这个SQL产生笛卡尔积了,找了半天不知道什么地方出错,求达人帮忙解决一下。。。
还有这个SQL可以查询我想要的结果:
select a.agt_id as agt_id,
a.agt_nme as agt_nme,
b.ob_task_no as ob_task_no,
b.ob_task_name as ob_task_name,
count(b.ob_call_no)
from t_cc_agt a,ob_result b
where a.agt_id=b.usr_id
and b.ob_task_no='888'
group by a.agt_id,a.agt_nme,b.ob_task_no,b.ob_task_name
这个SQL只查结果数量查询出来的就是对的,但联合分配表查询分配数量的时候就会产生笛卡尔积了!!
谢谢!
还有,我说一下我要查的东西:
通过输入一个任务编号
从员工表中查出员工的编号和名字,分配表中查询该任务编号下该员工的分配数量,结果表中查出该员工该任务下的的完成数量。。。