citem_id   iperiod   mb 

401             1            23520.00

401              2          256485.00

401             1          15642

需要查询分组citem_id,iperiod下最大值mb的语句:

SELECT citem_id,iperiod,mb,me,cbegind_c,cbegind_c_engl,ccode,cexch_name,cdept_id,cperson_id,ccus_id,csup_id,citem_class,md,mc,cendd_c,cendd_c_engl,mb_f,md_f,mc_f,me_f,nb_s,nd_s,nc_s,ne_s

FROM GL_accass tmp
WHERE (ccode = '218112')
  and mb=me
  and me>0
group by citem_id,iperiod,mb,me,cbegind_c,cbegind_c_engl,ccode,cexch_name,cdept_id,cperson_id,ccus_id,csup_id,citem_class,md,mc,cendd_c,cendd_c_engl,mb_f,md_f,mc_f,me_f,nb_s,nd_s,nc_s,ne_s
having (max(mb)>= all (select max(mb) from GL_accass where tmp.citem_id = citem_id and tmp.iperiod=iperiod group by citem_id,iperiod))
order by citem_id,iperiod