SQL 分组取前N名


MySQL 

   select t_a.* from table_name t_a where 1<= (

         select count(*) from 

         table_name t_b 

         where t_a.code = t_b.code 

         and t_a.rdate >= t_b.rdate 

          order by t_a.rdate desc

 )   

你可能感兴趣的:(SQL 分组取前N名)