SELECT * from ( select case when t.province=@prov then @rownum:=@rownum+1 else @rownum:=1 end rownum, case when t.province=@prov then 0 else @prov:=t.province end prov, t.* from ( SELECT ‘110000‘ province,1231 money UNION all SELECT ‘110000‘ province,123121 money UNION all SELECT ‘110000‘ province,1231231 money UNION all SELECT ‘120000‘ province,121231 money UNION all SELECT ‘120000‘ province,123121 money UNION all SELECT ‘130000‘ province,12131 money UNION all SELECT ‘130000‘ province,12231 money UNION all SELECT ‘140000‘ province,123311 money ) t,(select @rownum:=0) rn,(select @prov:=‘‘) prov ORDER BY t.province,t.money desc ) tt where tt.rownum<=2 ;