sql="select a.yuefen,SUM(a.dkhzd) AS xdkhys,SUM(b.dkhzd) AS xdkhys,SUM(b.xzmoney) AS xxzmoney from dkhhk AS A,dkhhk as b where id not in (select id from dkhhk where xzzt='完全销帐' or xzzt='核减销帐') GROUP BY a.yuefen"
或者: select a.yuefen,a.xdkhys1/b.xdkhys2,a.xxzmoney1/b.xxzmoney2 from ( select yuefen,SUM(dkhzd) AS xdkhys1,SUM(xzmoney) AS xxzmoney1 from dkhhk where xzzt not in('完全销帐','核减销帐') group by yuefen ) a inner join ( select yuefen,SUM(dkhzd) AS xdkhys2,SUM(xzmoney) AS xxzmoney2 from dkhhk group by yuefen )b on a.yuefen=b.yuefen