select bh,mc,max(sl)as expr,sum(xfwh.sl*xfwh.yl*xfwh.jg)as expr2 
from xfjlb,xfwh 
where (sx<>3) and (xfwh.cpbh=xfjlb.bh)and(xfwh.sj=xfjlb.sj)
group by bh,mc;

解决方案 »

  1.   

    你直接查询就知道为什么了:select bh,mc,sl,xfwh.sl,xfwh.yl,xfwh.jg
    from xfjlb,xfwh 
    where (sx<>3) and (xfwh.cpbh=xfjlb.bh)and(xfwh.sj=xfjlb.sj)
      

  2.   

    sx<>3時﹐沒有符合條件的記錄
      

  3.   

    select table1.bh,table1.mc,table1.expr,table2.expr2
    from (select xfjlb.bh,xfjlb.mc,sum(xfjlb.sl)as expr
    from xfjlb
    where (xfjlb.sx<>3) 
    group by xfjlb.bh,xfjlb.mc) table1
    left join
    (select cpbh,sj,sum(xfwh.sl*xfwh.yl*xfwh.jg)as expr2  from xfwh group by cpbh,sj) table2
    on (table2.cpbh=table1.bh)and(table2.sj=table1.sj)