select gr,num,dt,(select bys from test where gr=b.gr and dt=b.dt) bys from ( select gr,count(0) num,max(dt) dt from test group by gr ) b //如果有重复项,可用如下语句(针对Mysql的limit,Oracle 可用 rownum<2) select gr,num,dt,(select bys from test where gr=b.gr and dt=b.dt limit 1) bys from ( select gr,count(0) num,max(dt) dt from test group by gr ) b