这个不需要外连接,也不是外连接的问题
select a.cphm,a.jyl,b.行驶里程
from (select cphm,sum(jyl) from table_a group by cphm) a,
table_b b
where a.cphm=b.车牌号码;

解决方案 »

  1.   

    select * from table1,table2
    where table1.column1=table2.column1(+)
      

  2.   

    如果我想利用外连接,因为我给您举的这个例子比较简单,所以写起来比较容易点,但是我 的sql语句上边有好多条件,所以就比较长了,如果可能的话,我想
    select cphm,sum(jyl)from 表a group by cphm “+” select cphm,sum(xslc) from 表b group by cphm(其中的条件省略了)where a.cphm=b.cphm
    产生这样的效果车牌号吗      加油量          行驶里程
    cphm          jyl              xslc        
    1001           250              100
    1002           102               200
    不知能否利用外联接呢?
    恕在下愚蠢!请赐教!!!
      

  3.   

    正常情况下应该还会有一个车辆的表cselect c.cphm, sum(a.jyl) jyl, sum(b.xslc) xslc from a,b,c
    where c.cphm=b.cphm(+) and
          c.cphm=a.cphm(+)
    group by c.cphm