日期:2014-05-17 浏览次数:20450 次
select a.sjbh,a.sjmc,a.kssc,a.mtdw,sum(a.fz) as zf
from sjtmb a
inner join (select sjbh,max(autoid) as autoid from sjtmb group by sjbh) b
on a.autoid=b.autoid and a.sjbh=b.sjbh
group by a.sjbh,a.sjmc,a.kssc,a.mtdw
select a.sjbh,a.sjmc,a.kssc,a.mtdw,
(select sum(b.fz) from sjtmb b
where b.autoid=a.autoid --> 相同编号行的条件
) 'zf'
from sjtmb a