不考虑外连接:
select eb_no,eb_company,sum(ev_add) total,sum(ee_pay) totall 
from escustomers_vip, escustomers_base,escustomers_extend 
where ev_eb_no = eb_no and ee_eb_no = eb_no 
group by eb_no,eb_company
order by eb_no,eb_company;我这边暂时没环境,你先测试一下。
基本思想是:由于三张表都是通过EB_NO连接,先把他们连接查询,那么
结果集中应该包括公司所有的ev_add,ee_pay,然后再按eb_no分组取sum。

解决方案 »

  1.   

    不是吧。老兄,你真的被逼到这步了。哎..........
    笨办法是你在C和E里面最后的WHERE加上限制的条件。被逼在一条路上死掉,不如想办法换条路走走。尤其死掉,不如把那东东重新按你的意愿做过。
      

  2.   

    select b.eb_no,b.eb_company,sum(a.ev_add) over(order by order by a.ev_eb_no,b.eb_company) total,sum(ee_pay) over(order by a.ev_eb_no,b.eb_company) total1 from escustomers_vip a, escustomers_base b,escustomers_extend d where a.ev_eb_no=b.eb_no and d.ee_eb_no=b.eb_no order by a.ev_eb_no,b.eb_company