SELECT min (maxrank) as minofmaxrank FROM (SELECT max(rank) as maxrank FROM tbl_core_staff WHERE st_ymd<=now() AND ed_ymd>now() AND staff_cd in (‘‘,‘‘,‘‘,‘‘,‘‘,‘‘,‘‘,‘‘,‘‘,‘‘,‘‘,‘‘,‘‘,‘‘,‘‘,‘‘,‘‘,‘‘,‘‘) GROUP BY staff_cd ) t1
这里是先从tbl_core_staff 表查询分组的最大值的rank 然后查询这个最大值rank组的最小值