不考虑外连接:
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。
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。
笨办法是你在C和E里面最后的WHERE加上限制的条件。被逼在一条路上死掉,不如想办法换条路走走。尤其死掉,不如把那东东重新按你的意愿做过。