求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只查结果数量查询出来的就是对的,但联合分配表查询分配数量的时候就会产生笛卡尔积了!!

谢谢!
还有,我说一下我要查的东西:
通过输入一个任务编号
从员工表中查出员工的编号和名字,分配表中查询该任务编号下该员工的分配数量,结果表中查出该员工该任务下的的完成数量。。。

哥们,产生笛卡尔积的原因是第四句 c.ob_task_name as ob_task_name,
将 c.ob_task_name as ob_task_name去掉,然后在group by 中将c.ob_task_name去掉


PS:你的SQL写的极其混乱,不简便,多余语句太多了,看这样写行不?

select a.agt_id ,a.agt_nme ,b.ob_task_no ,count(b.ob_call_no) counter1,count(c.ob_call_no) 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.ob_task_no=c.ob_task_no
and b.ob_task_no='888'
group by a.agt_id,a.agt_nme,b.ob_task_no


谢谢回复~~~
兄弟,按照你的写法查询还是产生笛卡尔积了~~呵呵~~
再有,我用的是Informix数据库,不支持嵌套查询的~~
我是个新人~~呵呵,正在努力的学习中。。。。

哥们,可不可以把表结构给出拉,看下。才知道你错在那里啊